From 514abf030cf5ecbbc0e57669024ca54f7002eeab Mon Sep 17 00:00:00 2001 From: meetqy Date: Sat, 30 Mar 2024 10:53:39 +0800 Subject: [PATCH] fix: Make showing/hiding the clock configurable #159 --- src/UI/Settings/UIWindowSettings.js | 16 ++++++---------- src/UI/UIDesktop.js | 1 - src/UI/UITaskbar.js | 3 +++ src/helpers.js | 19 +++++++++++++++++++ 4 files changed, 28 insertions(+), 11 deletions(-) diff --git a/src/UI/Settings/UIWindowSettings.js b/src/UI/Settings/UIWindowSettings.js index 5418e4d3d..5587ea2ba 100644 --- a/src/UI/Settings/UIWindowSettings.js +++ b/src/UI/Settings/UIWindowSettings.js @@ -133,9 +133,9 @@ async function UIWindowSettings(options){ h += `
` h += `${i18n('click_visable')}:` h += `` h += `
` h += ``; @@ -361,15 +361,11 @@ async function UIWindowSettings(options){ const $this = $(this); const value = $this.val(); - value === 'show' && $('#clock').show(); - value === 'hide' && $('#clock').hide(); - - // save clock_visable to user preferences - window.mutate_user_preferences({ - clock_visable: value - }); + changeClockVisable(value); }) + change_clock_visable(); + resolve(el_window); }); } diff --git a/src/UI/UIDesktop.js b/src/UI/UIDesktop.js index e3c07f442..1b3724b31 100644 --- a/src/UI/UIDesktop.js +++ b/src/UI/UIDesktop.js @@ -1029,7 +1029,6 @@ async function UIDesktop(options){ } }) } - } $(document).on('contextmenu taphold', '.taskbar', function(event){ diff --git a/src/UI/UITaskbar.js b/src/UI/UITaskbar.js index b76cb899a..5d00082c1 100644 --- a/src/UI/UITaskbar.js +++ b/src/UI/UITaskbar.js @@ -45,6 +45,9 @@ async function UITaskbar(options){ $('.desktop').append(h); + // init clock visibility + window.change_clock_visable(); + //--------------------------------------------- // add `Start` to taskbar //--------------------------------------------- diff --git a/src/helpers.js b/src/helpers.js index cf3524594..21676a712 100644 --- a/src/helpers.js +++ b/src/helpers.js @@ -3676,4 +3676,23 @@ window.save_desktop_item_positions = ()=>{ window.delete_desktop_item_positions = ()=>{ desktop_item_positions = {} puter.kv.del('desktop_item_positions'); +} + +window.change_clock_visable = (clock_visable) => { + let newValue = clock_visable || window.user_preferences.clock_visable; + + newValue === 'show' && $('#clock').show(); + newValue === 'hide' && $('#clock').hide(); + + + if(clock_visable) { + // save clock_visable to user preferences + window.mutate_user_preferences({ + clock_visable: newValue + }); + + return; + } + + $('select.change-clock-visable').val(window.user_preferences.clock_visable); } \ No newline at end of file