Skip to content

Commit

Permalink
Update theme CSS on theme mode change
Browse files Browse the repository at this point in the history
  • Loading branch information
BrandonXLF committed Jul 8, 2024
1 parent a8d0632 commit 755844f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/window/Tab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 755844f

Please sign in to comment.