@@ -385,16 +385,14 @@ const stateWithSideEffects = {
385
385
await Promise . allSettled ( loadPromises )
386
386
387
387
i18n . locale = targetLocale
388
- await dispatch ( 'getRegionData' , {
389
- locale : targetLocale
390
- } )
388
+ await dispatch ( 'getRegionData' , targetLocale )
391
389
}
392
390
} ,
393
391
394
392
defaultInvidiousInstance : {
395
393
defaultValue : '' ,
396
- sideEffectsHandler : ( { commit, getters } , value ) => {
397
- if ( value !== '' && getters . getCurrentInvidiousInstance !== value ) {
394
+ sideEffectsHandler : ( { commit, rootState } , value ) => {
395
+ if ( value !== '' && rootState . invidious . currentInvidiousInstance !== value ) {
398
396
commit ( 'setCurrentInvidiousInstance' , value )
399
397
}
400
398
}
@@ -420,6 +418,8 @@ const stateWithSideEffects = {
420
418
}
421
419
}
422
420
421
+ const settingsWithSideEffects = Object . keys ( stateWithSideEffects )
422
+
423
423
const customState = {
424
424
}
425
425
@@ -428,28 +428,8 @@ const customGetters = {
428
428
429
429
const customMutations = { }
430
430
431
- /**********/
432
- /*
433
- * DO NOT TOUCH THIS SECTION
434
- * If you wanna add to custom data or logic to the module,
435
- * do so in the aproppriate `custom_` variable
436
- *
437
- * Some of the custom actions below use these properties, so I'll be
438
- * adding them here instead of further down for clarity's sake
439
- */
440
- Object . assign ( customState , {
441
- settingsWithSideEffects : Object . keys ( stateWithSideEffects )
442
- } )
443
-
444
- Object . assign ( customGetters , {
445
- settingHasSideEffects : ( state ) => {
446
- return ( id ) => state . settingsWithSideEffects . includes ( id )
447
- }
448
- } )
449
- /**********/
450
-
451
431
const customActions = {
452
- grabUserSettings : async ( { commit, dispatch, getters } ) => {
432
+ grabUserSettings : async ( { commit, dispatch } ) => {
453
433
try {
454
434
// Assigning default settings for settings that have side effects
455
435
const userSettings = Object . entries ( Object . assign ( { } ,
@@ -459,7 +439,7 @@ const customActions = {
459
439
460
440
for ( const setting of userSettings ) {
461
441
const [ _id , value ] = setting
462
- if ( getters . settingHasSideEffects ( _id ) ) {
442
+ if ( settingsWithSideEffects . includes ( _id ) ) {
463
443
dispatch ( defaultSideEffectsTriggerId ( _id ) , value )
464
444
}
465
445
@@ -473,14 +453,14 @@ const customActions = {
473
453
} ,
474
454
475
455
// Should be a root action, but we'll tolerate
476
- setupListenersToSyncWindows : ( { commit, dispatch, getters } ) => {
456
+ setupListenersToSyncWindows : ( { commit, dispatch } ) => {
477
457
if ( process . env . IS_ELECTRON ) {
478
458
const { ipcRenderer } = require ( 'electron' )
479
459
480
460
ipcRenderer . on ( IpcChannels . SYNC_SETTINGS , ( _ , { event, data } ) => {
481
461
switch ( event ) {
482
462
case SyncEvents . GENERAL . UPSERT :
483
- if ( getters . settingHasSideEffects ( data . _id ) ) {
463
+ if ( settingsWithSideEffects . includes ( data . _id ) ) {
484
464
dispatch ( defaultSideEffectsTriggerId ( data . _id ) , data . value )
485
465
}
486
466
@@ -615,15 +595,15 @@ for (const settingId of Object.keys(state)) {
615
595
mutations [ mutationId ] = ( state , value ) => { state [ settingId ] = value }
616
596
617
597
// If setting has side effects, generate action to handle them
618
- if ( Object . keys ( stateWithSideEffects ) . includes ( settingId ) ) {
598
+ if ( settingsWithSideEffects . includes ( settingId ) ) {
619
599
actions [ triggerId ] = stateWithSideEffects [ settingId ] . sideEffectsHandler
620
600
}
621
601
622
- actions [ updaterId ] = async ( { commit, dispatch, getters } , value ) => {
602
+ actions [ updaterId ] = async ( { commit, dispatch } , value ) => {
623
603
try {
624
604
await DBSettingHandlers . upsert ( settingId , value )
625
605
626
- if ( getters . settingHasSideEffects ( settingId ) ) {
606
+ if ( settingsWithSideEffects . includes ( settingId ) ) {
627
607
dispatch ( triggerId , value )
628
608
}
629
609
0 commit comments