@@ -5,10 +5,13 @@ import { defineStore, storeToRefs } from 'pinia';
5
5
6
6
import { computed , reactive , ref , toRaw } from 'vue' ;
7
7
8
+ import type { IconActions } from '~/models/icon-action' ;
9
+
8
10
import type { PosterItem } from '~/models/poster.model' ;
9
11
10
12
import NewExtensionIcon from '~/assets/brand/favicon-128x128.png' ;
11
13
import OldExtensionIcon from '~/assets/favicon/favicon-128x128.png' ;
14
+ import { IconAction } from '~/models/icon-action' ;
12
15
import { DefaultLists , type ListEntity } from '~/models/list.model' ;
13
16
import { MessageType } from '~/models/message/message-type.model' ;
14
17
import { NavbarPosition , type NavbarPositions } from '~/models/navbar-position.model' ;
@@ -118,6 +121,8 @@ export const DefaultQuickActionLists: QuickActionListDictionary = {
118
121
[ Route . Search ] : DefaultLists . Watchlist ,
119
122
} ;
120
123
124
+ const sendIconActionUpdate = debounce ( ( action : IconActions ) => sendMessage ( { type : MessageType . IconOptions , payload : { open : action } } ) , 500 ) ;
125
+
121
126
type ThemeColors = {
122
127
main ?: string ;
123
128
dark ?: string ;
@@ -144,6 +149,7 @@ type ExtensionSettings = {
144
149
actionDate : ActionDateDictionary ;
145
150
actionLists : QuickActionListDictionary ;
146
151
theme : ThemeColors ;
152
+ iconAction : IconActions ;
147
153
} ;
148
154
149
155
const ExtensionSettingsConstants = {
@@ -175,6 +181,8 @@ export const useExtensionSettingsStore = defineStore(ExtensionSettingsConstants.
175
181
const brand = ref < Brands > ( Brand . Old ) ;
176
182
const theme = reactive < ThemeColors > ( { background : 'transparent' } ) ;
177
183
184
+ const iconAction = ref < IconActions > ( IconAction . Popup ) ;
185
+
178
186
const clearState = ( ) => {
179
187
Object . assign ( cacheRetention , DefaultCacheRetention ) ;
180
188
Object . assign ( routeDictionary , DefaultRoutes ) ;
@@ -207,6 +215,7 @@ export const useExtensionSettingsStore = defineStore(ExtensionSettingsConstants.
207
215
actionDate : toRaw ( actionDate ) ,
208
216
actionLists : toRaw ( actionLists ) ,
209
217
theme : toRaw ( theme ) ,
218
+ iconAction : iconAction . value ,
210
219
} ) ,
211
220
500 ,
212
221
) ;
@@ -251,6 +260,7 @@ export const useExtensionSettingsStore = defineStore(ExtensionSettingsConstants.
251
260
if ( restored ?. actionLists !== undefined ) Object . assign ( actionLists , restored . actionLists ) ;
252
261
253
262
if ( restored ?. theme !== undefined ) Object . assign ( theme , restored . theme ) ;
263
+ if ( restored ?. iconAction !== undefined ) iconAction . value = restored . iconAction ;
254
264
255
265
if ( ! chromeRuntimeId ) routeDictionary [ Route . Progress ] = false ;
256
266
} ;
@@ -449,6 +459,14 @@ export const useExtensionSettingsStore = defineStore(ExtensionSettingsConstants.
449
459
saveState ( ) . catch ( err => Logger . error ( 'Failed to save icon only extension settings' , { value, err } ) ) ;
450
460
} ,
451
461
} ) ,
462
+ iconAction : computed < IconActions > ( {
463
+ get : ( ) => iconAction . value ,
464
+ set : ( value : IconActions ) => {
465
+ iconAction . value = value ;
466
+ sendIconActionUpdate ( value ) . catch ( err => Logger . error ( 'Failed to toggle icon action' , { value, err } ) ) ;
467
+ saveState ( ) . catch ( err => Logger . error ( 'Failed to save icon action extension settings' , { value, err } ) ) ;
468
+ } ,
469
+ } ) ,
452
470
getImageSettings,
453
471
setImageType,
454
472
setImageFormat,
0 commit comments