diff options
author | 2021-06-12 19:51:28 +0200 | |
---|---|---|
committer | 2021-06-12 19:51:28 +0200 | |
commit | b0ecce5eab2a6d0eed3ade7c43e252ca9bac7edb (patch) | |
tree | aed0253b61ca035f3388a7d6a369ffe75f195a58 /src/features/todos/store.js | |
parent | Bypassed code signing since that is also incorrect in GH settings. (diff) | |
download | ferdium-app-b0ecce5eab2a6d0eed3ade7c43e252ca9bac7edb.tar.gz ferdium-app-b0ecce5eab2a6d0eed3ade7c43e252ca9bac7edb.tar.zst ferdium-app-b0ecce5eab2a6d0eed3ade7c43e252ca9bac7edb.zip |
Fix active Todos service behaviour (#1481)
* Return false instead of null in isTodosServiceAdded
* Resolve from TODOS_RECIPES_ID instead of hardcoded TODOS_RECIPE_ID
* Fix TodosWebview width toggling when isTodosServiceActive
* Add more todo service recipe IDs
* Refactor todos state management
* Moved todos service URL and recipe ID computation logic to todos/store
* Simplified TodosWebview by delegating to the store for the URL and
removing the (unused) payment logic
* Made the todos service computation logic in the Service model depend
on the logic in todos/store
* Made ServicesStore depend on the todos service logic from the Service
model
* Todos appearance fixes
* Hide double horizontal rules if todo settings are hidden due to an
added todo service
* Hide todos panel border when the panel is hidden or expanded
* Make expanded todos panel obey sidebar width and vertical style
settings
* Make todos/store use isValidExternalURL
* Harden isValidExternalURL against malformed URLs
* Reduce todo URL string duplication in config.js
Co-authored-by: Kristóf Marussy <kristof@marussy.com>
Diffstat (limited to 'src/features/todos/store.js')
-rw-r--r-- | src/features/todos/store.js | 29 |
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 { | |||
7 | import localStorage from 'mobx-localstorage'; | 7 | import localStorage from 'mobx-localstorage'; |
8 | 8 | ||
9 | import { todoActions } from './actions'; | 9 | import { todoActions } from './actions'; |
10 | import { CUSTOM_TODO_SERVICE, TODO_SERVICE_RECIPE_IDS } from '../../config'; | ||
11 | import { isValidExternalURL } from '../../helpers/url-helpers'; | ||
10 | import { FeatureStore } from '../utils/FeatureStore'; | 12 | import { FeatureStore } from '../utils/FeatureStore'; |
11 | import { createReactions } from '../../stores/lib/Reaction'; | 13 | import { createReactions } from '../../stores/lib/Reaction'; |
12 | import { createActionBindings } from '../utils/ActionBinding'; | 14 | import { createActionBindings } from '../utils/ActionBinding'; |
@@ -21,6 +23,8 @@ import UserAgent from '../../models/UserAgent'; | |||
21 | const debug = require('debug')('Ferdi:feature:todos:store'); | 23 | const debug = require('debug')('Ferdi:feature:todos:store'); |
22 | 24 | ||
23 | export default class TodoStore extends FeatureStore { | 25 | export 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) { |