aboutsummaryrefslogtreecommitdiffstats
path: root/src/features/todos/store.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/features/todos/store.js')
-rw-r--r--src/features/todos/store.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/features/todos/store.js b/src/features/todos/store.js
index af8519d9c..4febd7bb1 100644
--- a/src/features/todos/store.js
+++ b/src/features/todos/store.js
@@ -7,6 +7,8 @@ import {
7import localStorage from 'mobx-localstorage'; 7import localStorage from 'mobx-localstorage';
8 8
9import { todoActions } from './actions'; 9import { todoActions } from './actions';
10import { CUSTOM_TODO_SERVICE, TODO_SERVICE_RECIPE_IDS } from '../../config';
11import { isValidExternalURL } from '../../helpers/url-helpers';
10import { FeatureStore } from '../utils/FeatureStore'; 12import { FeatureStore } from '../utils/FeatureStore';
11import { createReactions } from '../../stores/lib/Reaction'; 13import { createReactions } from '../../stores/lib/Reaction';
12import { createActionBindings } from '../utils/ActionBinding'; 14import { createActionBindings } from '../utils/ActionBinding';
@@ -21,6 +23,8 @@ import UserAgent from '../../models/UserAgent';
21const debug = require('debug')('Ferdi:feature:todos:store'); 23const debug = require('debug')('Ferdi:feature:todos:store');
22 24
23export default class TodoStore extends FeatureStore { 25export default class TodoStore extends FeatureStore {
26 @observable stores = null;
27
24 @observable isFeatureEnabled = false; 28 @observable isFeatureEnabled = false;
25 29
26 @observable isFeatureActive = false; 30 @observable isFeatureActive = false;
@@ -59,6 +63,31 @@ export default class TodoStore extends FeatureStore {
59 return this.userAgentModel.userAgent; 63 return this.userAgentModel.userAgent;
60 } 64 }
61 65
66 @computed get isUsingPredefinedTodoServer() {
67 return this.stores && this.stores.settings.app.predefinedTodoServer !== CUSTOM_TODO_SERVICE;
68 }
69
70 @computed get todoUrl() {
71 if (!this.stores) {
72 return null;
73 }
74 return this.isUsingPredefinedTodoServer
75 ? this.stores.settings.app.predefinedTodoServer
76 : this.stores.settings.app.customTodoServer;
77 }
78
79 @computed get isTodoUrlValid() {
80 return !this.isUsingPredefinedTodoServer || isValidExternalURL(this.todoUrl);
81 }
82
83 @computed get todoRecipeId() {
84 if (this.isFeatureEnabledByUser && this.isUsingPredefinedTodoServer
85 && this.todoUrl in TODO_SERVICE_RECIPE_IDS) {
86 return TODO_SERVICE_RECIPE_IDS[this.todoUrl];
87 }
88 return null;
89 }
90
62 // ========== PUBLIC API ========= // 91 // ========== PUBLIC API ========= //
63 92
64 @action start(stores, actions) { 93 @action start(stores, actions) {