Skip to content

Commit

Permalink
Only show pause timer toggle when necessary
Browse files Browse the repository at this point in the history
The pause timer toggle button is hidden when auto fetching is
deactivated. It becomes visible only when auto fetching is enabled.
  • Loading branch information
ifl0w committed Dec 22, 2023
1 parent 9484b4f commit 0290474
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/randomWallpaperMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,25 @@ class RandomWallpaperMenu {

// Temporarily pause timer
const pauseTimerItem = new PopupMenu.PopupSwitchMenuItem('Pause timer', false);
pauseTimerItem.sensitive = this._settings.getBoolean('auto-fetch');
pauseTimerItem.setToggleState(this._backendConnection.getBoolean('pause-timer'));

pauseTimerItem.connect('toggled', (_, state: boolean) => {
this._backendConnection.setBoolean('pause-timer', state);
});

this._observedValues.push(this._settings.observe('auto-fetch', () => {
pauseTimerItem.sensitive = this._settings.getBoolean('auto-fetch');
}));
const autoFetchChangedCallback = (): void => {
if (this._settings.getBoolean('auto-fetch'))
pauseTimerItem.show();
else
pauseTimerItem.hide();
};
this._observedValues.push(this._settings.observe('auto-fetch', autoFetchChangedCallback));
autoFetchChangedCallback();

this._observedBackgroundValues.push(this._backendConnection.observe('pause-timer', () => {
const pauseTimerChangedCallback = (): void => {
pauseTimerItem.setToggleState(this._backendConnection.getBoolean('pause-timer'));
}));
};
this._observedBackgroundValues.push(this._backendConnection.observe('pause-timer', pauseTimerChangedCallback));
pauseTimerChangedCallback();

this._panelMenu.menu.addMenuItem(pauseTimerItem);

Expand Down

0 comments on commit 0290474

Please sign in to comment.