aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--static/main.ts8
-rw-r--r--static/real-dark.ts11
-rw-r--r--static/settings.ts4
3 files changed, 19 insertions, 4 deletions
diff --git a/static/main.ts b/static/main.ts
index 215de7648..3b0654449 100644
--- a/static/main.ts
+++ b/static/main.ts
@@ -67,7 +67,7 @@ import * as utils from '../shared/common-utils.js';
import {Printerinator} from './print-view.js';
import {formatISODate, updateAndCalcTopBarHeight} from './utils.js';
import {localStorage, sessionThenLocalStorage} from './local.js';
-import {setup_real_dark} from './real-dark.js';
+import {setupRealDark, takeUsersOutOfRealDark} from './real-dark.js';
const logos = require.context('../views/resources/logos', false, /\.(png|svg)$/);
@@ -119,7 +119,7 @@ function setupSettings(hub: Hub): [Themer, SiteSettings] {
}
$('#settings').find('.editorsFFont').css('font-family', newSettings.editorsFFont);
currentSettings = newSettings;
- localStorage.set('settings', JSON.stringify(newSettings));
+ Settings.setStoredSettings(newSettings);
eventHub.emit('settingsChange', newSettings);
}
@@ -577,6 +577,8 @@ function sizeCheckNavHideables() {
// eslint-disable-next-line max-statements
function start() {
+ takeUsersOutOfRealDark();
+
initializeResetLayoutLink();
const hostnameParts = window.location.hostname.split('.');
@@ -747,7 +749,7 @@ function start() {
$('[name="editor-btn-toolbar"]').addClass('d-none');
}
- setup_real_dark(hub);
+ setupRealDark(hub);
window.onSponsorClick = (sponsorUrl: string) => {
analytics.proxy('send', {
diff --git a/static/real-dark.ts b/static/real-dark.ts
index 9fa0aa5e1..710e8a087 100644
--- a/static/real-dark.ts
+++ b/static/real-dark.ts
@@ -17,7 +17,16 @@ function toggleButton() {
);
}
-export function setup_real_dark(hub: Hub) {
+export function takeUsersOutOfRealDark() {
+ // take user out of real-dark in case they got stuck previously
+ if (Settings.getStoredSettings().theme === 'real-dark') {
+ const settings = Settings.getStoredSettings();
+ settings.theme = 'dark';
+ Settings.setStoredSettings(settings);
+ }
+}
+
+export function setupRealDark(hub: Hub) {
const overlay = $('#real-dark');
let overlay_on = false;
const toggleOverlay = () => {
diff --git a/static/settings.ts b/static/settings.ts
index 3826fdbb4..bbd561373 100644
--- a/static/settings.ts
+++ b/static/settings.ts
@@ -235,6 +235,10 @@ export class Settings {
return JSON.parse(localStorage.get('settings', '{}'));
}
+ public static setStoredSettings(newSettings: SiteSettings) {
+ localStorage.set('settings', JSON.stringify(newSettings));
+ }
+
public setSettings(newSettings: SiteSettings) {
this.onSettingsChange(newSettings);
this.onChange(newSettings);