Skip to content

Commit f2190c2

Browse files
committed
Defer dark/light mode integration to DevDocs
1 parent 76af65e commit f2190c2

File tree

3 files changed

+0
-55
lines changed

3 files changed

+0
-55
lines changed

devdocs-macos/DocumentationViewController.swift

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,6 @@ class DocumentationViewController: NSViewController {
125125

126126
// MARK:- JS integration
127127

128-
func useDarkMode(_ using: Bool) {
129-
if using {
130-
webView.evaluateJavaScript("useDarkMode(true);")
131-
} else {
132-
webView.evaluateJavaScript("useDarkMode(false);")
133-
}
134-
}
135-
136128
func useNativeScrollbars(_ using: Bool) {
137129
if using {
138130
webView.evaluateJavaScript("useNativeScrollbars(true);")

devdocs-macos/DocumentationWindowController.swift

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ class DocumentationWindowController: NSWindowController {
2323
}
2424

2525
override func windowDidLoad() {
26-
observeEffectiveAppearance()
27-
2826
guard let dvc = documentationViewController else { return }
2927

3028
NotificationCenter.default.addObserver(self,
@@ -59,16 +57,6 @@ class DocumentationWindowController: NSWindowController {
5957

6058
dvc.overridePreferencesExport()
6159
dvc.useNativeScrollbars(true)
62-
63-
guard let window = self.window else { return }
64-
switch window.effectiveAppearance.name {
65-
case .aqua:
66-
dvc.useDarkMode(false)
67-
case .darkAqua:
68-
dvc.useDarkMode(true)
69-
default:
70-
break;
71-
}
7260
}
7361

7462
@objc private func observeDocumentTitle() {
@@ -90,27 +78,6 @@ class DocumentationWindowController: NSWindowController {
9078
guard let dvc = documentationViewController else { return }
9179
dvc.showSearchControl()
9280
}
93-
94-
// MARK:- KVO observers
95-
96-
private func observeEffectiveAppearance() {
97-
guard let window = self.window else { return }
98-
observations.insert(
99-
window.observe(\NSWindow.effectiveAppearance) { [weak self] (win, _) in
100-
guard let dvc = self?.documentationViewController else {
101-
return
102-
}
103-
switch window.effectiveAppearance.name {
104-
case .aqua:
105-
dvc.useDarkMode(false)
106-
case .darkAqua:
107-
dvc.useDarkMode(true)
108-
default:
109-
break;
110-
}
111-
}
112-
)
113-
}
11481
}
11582

11683
// MARK:- DocumentationViewDelegate

devdocs-macos/user-scripts/ui-settings.js

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,5 @@
11
/* global app */
22

3-
window.useDarkMode = function (enable) {
4-
requestAnimationFrame(() => {
5-
const inDarkMode = !!app.settings.get('dark')
6-
if (enable && inDarkMode) {
7-
return
8-
}
9-
if (!enable && !inDarkMode) {
10-
return
11-
}
12-
const sp = new app.views.SettingsPage()
13-
sp.toggleDark(enable)
14-
})
15-
}
16-
173
window.useNativeScrollbars = function (enable) {
184
requestAnimationFrame(() => {
195
const sp = new app.views.SettingsPage()

0 commit comments

Comments
 (0)