Patch highlighting color scheme setting bug (#4622)

This commit is contained in:
Jeremy Rifkin
2023-01-20 05:12:46 -05:00
committed by GitHub
parent c6a548c765
commit 41db591c54

View File

@@ -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';
@@ -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;
@@ -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;
}