Skip to content

Commit

Permalink
Patch highlighting color scheme setting bug (#4622)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremy-rifkin committed Jan 20, 2023
1 parent c6a548c commit 41db591
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions static/settings.ts
Expand Up @@ -30,7 +30,7 @@ import {themes, Themes} from './themes';
import {AppTheme, ColourScheme, ColourSchemeInfo} from './colour';
import {Hub} from './hub';
import {EventHub} from './event-hub';
import {keys} from '../lib/common-utils';
import {keys, isString} from '../lib/common-utils';
import {assert, unwrapString} from './assert';

import {LanguageKey} from '../types/languages.interfaces';
Expand Down Expand Up @@ -459,12 +459,16 @@ export class Settings {
const themeSelect = this.root.find('.theme');
const colourSchemeSelect = this.root.find('.colourScheme');

if (!colourSchemeSelect.val()) {
return;
}
const oldScheme = unwrapString(colourSchemeSelect.val());
const oldScheme = colourSchemeSelect.val();
const newTheme = unwrapString<colour.AppTheme>(themeSelect.val());

// Small check to make sure we aren't getting something completely unexpected, like a string[] or number
assert(
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
isString(oldScheme) || oldScheme === undefined || oldScheme == null,
'Unexpected value received from colourSchemeSelect.val()'
);

this.fillColourSchemeSelector(colourSchemeSelect, newTheme);
const newThemeStoredScheme = $.data(themeSelect, 'theme-' + newTheme) as colour.AppTheme | undefined;

Expand All @@ -473,7 +477,7 @@ export class Settings {
// If we have one old one stored, check if it's still valid and set it if so
if (newThemeStoredScheme && this.selectorHasOption(colourSchemeSelect, newThemeStoredScheme)) {
newScheme = newThemeStoredScheme;
} else if (this.selectorHasOption(colourSchemeSelect, oldScheme)) {
} else if (isString(oldScheme) && this.selectorHasOption(colourSchemeSelect, oldScheme)) {
newScheme = oldScheme;
}

Expand Down

0 comments on commit 41db591

Please sign in to comment.