File tree Expand file tree Collapse file tree 2 files changed +29
-4
lines changed Expand file tree Collapse file tree 2 files changed +29
-4
lines changed Original file line number Diff line number Diff line change @@ -86,9 +86,7 @@ function tabReadyHandler(tab) {
86
86
const webview = /** @type {WebviewTag } */ ( tab . webview ) ;
87
87
88
88
tab . once ( "webview-dom-ready" , ( ) => {
89
- tab . on ( "active" , ( ) => {
90
- webview . send ( THEME_TAB_EVENTS . REQUEST_UPDATE ) ;
91
- } ) ;
89
+ tab . on ( "active" , ( ) => requestTabTheme ( tab ) ) ;
92
90
} ) ;
93
91
tab . element . addEventListener ( "contextmenu" , ( event ) => {
94
92
event . preventDefault ( ) ;
@@ -108,6 +106,26 @@ function tabReadyHandler(tab) {
108
106
} ) ;
109
107
}
110
108
109
+ /**
110
+ * Calls a tab and requests a theme update send-out.
111
+ * If no tab is provided, calls the active tab.
112
+ *
113
+ * @param {Tab = } tab
114
+ */
115
+ async function requestTabTheme ( tab ) {
116
+ tab = tab || ( await getActiveTab ( ) ) ;
117
+
118
+ if ( tab ) {
119
+ const webview = /** @type {WebviewTag } */ ( tab . webview ) ;
120
+ webview ?. send ( THEME_TAB_EVENTS . REQUEST_UPDATE ) ;
121
+ }
122
+ }
123
+
124
+ async function getActiveTab ( ) {
125
+ const tabGroup = await getTabGroup ( ) ;
126
+ return tabGroup ?. getActiveTab ( ) ;
127
+ }
128
+
111
129
async function getTabGroup ( ) {
112
130
return /** @type {TabGroup | null } */ (
113
131
await getIncludedElement ( "tab-group" , "#include-tabs" )
Original file line number Diff line number Diff line change @@ -40,9 +40,16 @@ async function prepareForm(themeSetting) {
40
40
const value = target instanceof HTMLSelectElement && target . value ;
41
41
42
42
if ( isThemeSetting ( value ) ) {
43
- currentThemeSetting = value ;
43
+ const isTabTheme = value === "tab" ;
44
44
45
+ currentThemeSetting = value ;
45
46
localStorage . setItem ( THEME_STORE_KEY , value ) ;
47
+
48
+ if ( isTabTheme ) {
49
+ requestTabTheme ( ) ;
50
+ return ;
51
+ }
52
+
46
53
setTheme ( value ) ;
47
54
} else {
48
55
currentThemeSetting = null ;
You can’t perform that action at this time.
0 commit comments