Use SignalContext instead of SignalWindow

This commit is contained in:
Josh Perez 2021-10-07 19:28:47 -04:00 committed by GitHub
parent a70a8a88d6
commit 75dab30367
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
35 changed files with 180 additions and 231 deletions

View file

@ -2,13 +2,13 @@
// SPDX-License-Identifier: AGPL-3.0-only
async function applyTheme() {
const theme = await window.SignalWindow.Settings.themeSetting.getValue();
const theme = await window.SignalContext.Settings.themeSetting.getValue();
document.body.classList.remove('light-theme');
document.body.classList.remove('dark-theme');
document.body.classList.add(
`${
theme === 'system'
? window.SignalWindow.context.nativeThemeListener.getSystemTheme()
? window.SignalContext.nativeThemeListener.getSystemTheme()
: theme
}-theme`
);
@ -18,7 +18,7 @@ async function applyThemeLoop() {
// eslint-disable-next-line no-constant-condition
while (true) {
// eslint-disable-next-line no-await-in-loop
await window.SignalWindow.Settings.waitForChange();
await window.SignalContext.Settings.waitForChange();
// eslint-disable-next-line no-await-in-loop
await applyTheme();
@ -28,6 +28,6 @@ async function applyThemeLoop() {
applyTheme();
applyThemeLoop();
window.SignalWindow.context.nativeThemeListener.subscribe(() => {
window.SignalContext.nativeThemeListener.subscribe(() => {
applyTheme();
});