mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Fix updating header background in webview (#29668)
This regressed in https://github.com/discourse/discourse/pull/28912 for media query changes.
This commit is contained in:
parent
6912a1e3ca
commit
20effebd51
@ -5,13 +5,19 @@ import discourseLater from "discourse-common/lib/later";
|
|||||||
export default {
|
export default {
|
||||||
after: "inject-objects",
|
after: "inject-objects",
|
||||||
retryCount: 0,
|
retryCount: 0,
|
||||||
|
isAppWebview: undefined,
|
||||||
|
mediaQuery: "(prefers-color-scheme: dark)",
|
||||||
|
|
||||||
initialize(owner) {
|
initialize(owner) {
|
||||||
const caps = owner.lookup("service:capabilities");
|
if (this.isAppWebview === undefined) {
|
||||||
if (caps.isAppWebview) {
|
const caps = owner.lookup("service:capabilities");
|
||||||
|
this.isAppWebview = caps.isAppWebview;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.isAppWebview) {
|
||||||
window
|
window
|
||||||
.matchMedia("(prefers-color-scheme: dark)")
|
.matchMedia(this.mediaQuery)
|
||||||
.addEventListener("change", this.updateAppBackground);
|
.addEventListener("change", this.updateAppBackground.bind(this));
|
||||||
this.updateAppBackground();
|
this.updateAppBackground();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -39,4 +45,12 @@ export default {
|
|||||||
this.updateAppBackground(1000);
|
this.updateAppBackground(1000);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
teardown() {
|
||||||
|
if (this.isAppWebview) {
|
||||||
|
window
|
||||||
|
.matchMedia(this.mediaQuery)
|
||||||
|
.removeEventListener("change", this.updateAppBackground.bind(this));
|
||||||
|
}
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user