1717 class =" filled-in"
1818 id =" viewTimeInBadge"
1919 v-model =" viewTimeInBadge"
20+ @change =" onChange(StorageParams.VIEW_TIME_IN_BADGE, $event.target.checked)"
2021 />
2122 <span >Display time tracker in icon</span >
2223 <p class =" description" >
3132 class =" filled-in"
3233 id =" blockDeferral"
3334 v-model =" allowDeferringBlock"
35+ @change =" onChange(StorageParams.BLOCK_DEFERRAL, $event.target.checked)"
3436 />
3537 <span >Allow deferring block for 5 minutes</span >
3638 <p class =" description" >
4042 </div >
4143 <div class =" settings-item" >
4244 <label class =" setting-header" >
43- <input type =" checkbox" class =" filled-in" id =" darkMode" v-model =" darkMode" />
45+ <input
46+ type =" checkbox"
47+ class =" filled-in"
48+ id =" darkMode"
49+ v-model =" darkMode"
50+ @change =" onChange(StorageParams.DARK_MODE, $event.target.checked)"
51+ />
4452 <span >Dark mode</span >
4553 <p class =" description" >Dark theme</p >
4654 </label >
5058 >Stop tracking if there is no activity during:
5159 </label >
5260 <div class =" d-inline-block ml-10" >
53- <select class =" option" v-model =" intervalInactivity" >
61+ <select
62+ class =" option"
63+ v-model =" intervalInactivity"
64+ @change =" onChange(StorageParams.INTERVAL_INACTIVITY, $event.target.value)"
65+ >
5466 <option :value =" InactivityInterval.Seconds_30" >30 seconds</option >
5567 <option :value =" InactivityInterval.Seconds_45" >45 seconds</option >
5668 <option :value =" InactivityInterval.Min_1" >1 min</option >
@@ -195,14 +207,8 @@ onMounted(async () => {
195207 whiteList .value = await settingsStorage .getValue (StorageParams .BLACK_LIST , []);
196208});
197209
198- watchEffect (async () => await save (StorageParams .VIEW_TIME_IN_BADGE , viewTimeInBadge .value ));
199- watchEffect (async () => await save (StorageParams .INTERVAL_INACTIVITY , intervalInactivity .value ));
200- watchEffect (async () => await save (StorageParams .DARK_MODE , darkMode .value ));
201- watchEffect (async () => await save (StorageParams .BLOCK_DEFERRAL , allowDeferringBlock .value ));
202- watchEffect (async () => await save (StorageParams .BLACK_LIST , whiteList .value ));
203-
204210async function save(storageParam : StorageParams , value : any ) {
205- await settingsStorage .saveValue (storageParam , value );
211+ if ( value != undefined ) await settingsStorage .saveValue (storageParam , value );
206212}
207213
208214async function addWebsite() {
@@ -216,8 +222,14 @@ async function addWebsite() {
216222 });
217223 } else {
218224 whiteList .value ?.push (newWebsiteForWhiteList .value ! );
225+ onChange (StorageParams .BLACK_LIST , whiteList .value );
226+ newWebsiteForWhiteList .value = ' ' ;
219227 }
220228}
229+
230+ function onChange(storageParam : StorageParams , value : any ) {
231+ save (storageParam , value );
232+ }
221233 </script >
222234
223235<style scoped>
0 commit comments