From 755844f686626dbc9bf1d5076552c6ff732df566 Mon Sep 17 00:00:00 2001 From: Brandon Fowler Date: Mon, 8 Jul 2024 02:35:56 -0400 Subject: [PATCH] Update theme CSS on theme mode change --- src/window/Tab.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/window/Tab.ts b/src/window/Tab.ts index 801f3fb..9a7a583 100644 --- a/src/window/Tab.ts +++ b/src/window/Tab.ts @@ -23,6 +23,7 @@ export default class Tab { titleElement = document.createElement('span'); closeButton = document.createElement('button'); unsavedIndicator = document.createElement('div'); + onThemeChange: () => void; removeCSSUpdateListener?: () => void; editorSession: Ace.EditSession; @@ -52,9 +53,12 @@ export default class Tab { this.updateWebviewCSS(); }); + this.onThemeChange = () => void this.updateWebviewCSS(); + this.tabStore.themeMode.on('change', this.onThemeChange); + this.removeCSSUpdateListener = this.tabStore.settings.listen( 'viewerUseTheme', - () => void this.updateWebviewCSS() + this.onThemeChange ); this.webview.addEventListener('did-finish-load', () => { @@ -383,6 +387,7 @@ export default class Tab { this.tabElement.remove(); this.webviewSubContainer.remove(); this.devtools.remove(); + this.tabStore.themeMode.removeListener('change', this.onThemeChange); this.removeCSSUpdateListener?.(); ipcRenderer.send('delete-session', this.partition); }