aboutsummaryrefslogtreecommitdiffstats
path: root/src/features/todos
diff options
context:
space:
mode:
authorLibravatar Stefan Malzner <stefan@adlk.io>2019-09-07 00:53:10 +0200
committerLibravatar Stefan Malzner <stefan@adlk.io>2019-09-07 00:53:10 +0200
commit5d03b91dd789ffd6d3d5753c223b4b6412887220 (patch)
treeb48a93aadcd5e77cd4f42d635edc598255286d4f /src/features/todos
parentUpdate CHANGELOG.md (diff)
downloadferdium-app-5d03b91dd789ffd6d3d5753c223b4b6412887220.tar.gz
ferdium-app-5d03b91dd789ffd6d3d5753c223b4b6412887220.tar.zst
ferdium-app-5d03b91dd789ffd6d3d5753c223b4b6412887220.zip
feat(Todos): Add option to disable todos
Diffstat (limited to 'src/features/todos')
-rw-r--r--src/features/todos/actions.js1
-rw-r--r--src/features/todos/index.js1
-rw-r--r--src/features/todos/store.js19
3 files changed, 19 insertions, 2 deletions
diff --git a/src/features/todos/actions.js b/src/features/todos/actions.js
index dc63d5fcd..1ccc9a592 100644
--- a/src/features/todos/actions.js
+++ b/src/features/todos/actions.js
@@ -6,6 +6,7 @@ export const todoActions = createActionsFromDefinitions({
6 width: PropTypes.number.isRequired, 6 width: PropTypes.number.isRequired,
7 }, 7 },
8 toggleTodosPanel: {}, 8 toggleTodosPanel: {},
9 toggleTodosFeatureVisibility: {},
9 setTodosWebview: { 10 setTodosWebview: {
10 webview: PropTypes.instanceOf(Element).isRequired, 11 webview: PropTypes.instanceOf(Element).isRequired,
11 }, 12 },
diff --git a/src/features/todos/index.js b/src/features/todos/index.js
index 9b6ab00a0..7388aebaf 100644
--- a/src/features/todos/index.js
+++ b/src/features/todos/index.js
@@ -8,6 +8,7 @@ export const GA_CATEGORY_TODOS = 'Todos';
8export const DEFAULT_TODOS_WIDTH = 300; 8export const DEFAULT_TODOS_WIDTH = 300;
9export const TODOS_MIN_WIDTH = 200; 9export const TODOS_MIN_WIDTH = 200;
10export const DEFAULT_TODOS_VISIBLE = true; 10export const DEFAULT_TODOS_VISIBLE = true;
11export const DEFAULT_IS_FEATURE_ENABLED_BY_USER = true;
11 12
12export const TODOS_ROUTES = { 13export const TODOS_ROUTES = {
13 TARGET: '/todos', 14 TARGET: '/todos',
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';
11import { createReactions } from '../../stores/lib/Reaction'; 11import { createReactions } from '../../stores/lib/Reaction';
12import { createActionBindings } from '../utils/ActionBinding'; 12import { createActionBindings } from '../utils/ActionBinding';
13import { 13import {
14 DEFAULT_TODOS_WIDTH, TODOS_MIN_WIDTH, DEFAULT_TODOS_VISIBLE, TODOS_ROUTES, 14 DEFAULT_TODOS_WIDTH, TODOS_MIN_WIDTH, DEFAULT_TODOS_VISIBLE, TODOS_ROUTES, DEFAULT_IS_FEATURE_ENABLED_BY_USER,
15} from '.'; 15} from '.';
16import { IPC } from './constants'; 16import { IPC } from './constants';
17import { state as delayAppState } from '../delayApp'; 17import { state as delayAppState } from '../delayApp';
@@ -33,7 +33,7 @@ export default class TodoStore extends FeatureStore {
33 33
34 @computed get isTodosPanelForceHidden() { 34 @computed get isTodosPanelForceHidden() {
35 const { isAnnouncementShown } = this.stores.announcements; 35 const { isAnnouncementShown } = this.stores.announcements;
36 return delayAppState.isDelayAppScreenVisible || isAnnouncementShown; 36 return delayAppState.isDelayAppScreenVisible || !this.settings.isFeatureEnabledByUser || isAnnouncementShown;
37 } 37 }
38 38
39 @computed get isTodosPanelVisible() { 39 @computed get isTodosPanelVisible() {
@@ -60,6 +60,7 @@ export default class TodoStore extends FeatureStore {
60 [todoActions.setTodosWebview, this._setTodosWebview], 60 [todoActions.setTodosWebview, this._setTodosWebview],
61 [todoActions.handleHostMessage, this._handleHostMessage], 61 [todoActions.handleHostMessage, this._handleHostMessage],
62 [todoActions.handleClientMessage, this._handleClientMessage], 62 [todoActions.handleClientMessage, this._handleClientMessage],
63 [todoActions.toggleTodosFeatureVisibility, this._toggleTodosFeatureVisibility],
63 ])); 64 ]));
64 65
65 // REACTIONS 66 // REACTIONS
@@ -74,6 +75,12 @@ export default class TodoStore extends FeatureStore {
74 this._registerReactions(this._allReactions); 75 this._registerReactions(this._allReactions);
75 76
76 this.isFeatureActive = true; 77 this.isFeatureActive = true;
78
79 if (this.settings.isFeatureEnabledByUser === undefined) {
80 this._updateSettings({
81 isFeatureEnabledByUser: DEFAULT_IS_FEATURE_ENABLED_BY_USER,
82 });
83 }
77 } 84 }
78 85
79 @action stop() { 86 @action stop() {
@@ -128,6 +135,14 @@ export default class TodoStore extends FeatureStore {
128 } 135 }
129 }; 136 };
130 137
138 @action _toggleTodosFeatureVisibility = () => {
139 debug('_toggleTodosFeatureVisibility');
140
141 this._updateSettings({
142 isFeatureEnabledByUser: !this.settings.isFeatureEnabledByUser,
143 });
144 };
145
131 // Todos client message handlers 146 // Todos client message handlers
132 147
133 _onTodosClientInitialized = () => { 148 _onTodosClientInitialized = () => {