From 5d03b91dd789ffd6d3d5753c223b4b6412887220 Mon Sep 17 00:00:00 2001 From: Stefan Malzner Date: Sat, 7 Sep 2019 00:53:10 +0200 Subject: feat(Todos): Add option to disable todos --- src/features/todos/store.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'src/features/todos/store.js') diff --git a/src/features/todos/store.js b/src/features/todos/store.js index 003c69a5b..05eef4ec1 100644 --- a/src/features/todos/store.js +++ b/src/features/todos/store.js @@ -11,7 +11,7 @@ import { FeatureStore } from '../utils/FeatureStore'; import { createReactions } from '../../stores/lib/Reaction'; import { createActionBindings } from '../utils/ActionBinding'; import { - DEFAULT_TODOS_WIDTH, TODOS_MIN_WIDTH, DEFAULT_TODOS_VISIBLE, TODOS_ROUTES, + DEFAULT_TODOS_WIDTH, TODOS_MIN_WIDTH, DEFAULT_TODOS_VISIBLE, TODOS_ROUTES, DEFAULT_IS_FEATURE_ENABLED_BY_USER, } from '.'; import { IPC } from './constants'; import { state as delayAppState } from '../delayApp'; @@ -33,7 +33,7 @@ export default class TodoStore extends FeatureStore { @computed get isTodosPanelForceHidden() { const { isAnnouncementShown } = this.stores.announcements; - return delayAppState.isDelayAppScreenVisible || isAnnouncementShown; + return delayAppState.isDelayAppScreenVisible || !this.settings.isFeatureEnabledByUser || isAnnouncementShown; } @computed get isTodosPanelVisible() { @@ -60,6 +60,7 @@ export default class TodoStore extends FeatureStore { [todoActions.setTodosWebview, this._setTodosWebview], [todoActions.handleHostMessage, this._handleHostMessage], [todoActions.handleClientMessage, this._handleClientMessage], + [todoActions.toggleTodosFeatureVisibility, this._toggleTodosFeatureVisibility], ])); // REACTIONS @@ -74,6 +75,12 @@ export default class TodoStore extends FeatureStore { this._registerReactions(this._allReactions); this.isFeatureActive = true; + + if (this.settings.isFeatureEnabledByUser === undefined) { + this._updateSettings({ + isFeatureEnabledByUser: DEFAULT_IS_FEATURE_ENABLED_BY_USER, + }); + } } @action stop() { @@ -128,6 +135,14 @@ export default class TodoStore extends FeatureStore { } }; + @action _toggleTodosFeatureVisibility = () => { + debug('_toggleTodosFeatureVisibility'); + + this._updateSettings({ + isFeatureEnabledByUser: !this.settings.isFeatureEnabledByUser, + }); + }; + // Todos client message handlers _onTodosClientInitialized = () => { -- cgit v1.2.3-70-g09d2