diff options
author | Stefan Malzner <stefan@adlk.io> | 2017-10-13 12:29:40 +0200 |
---|---|---|
committer | Stefan Malzner <stefan@adlk.io> | 2017-10-13 12:29:40 +0200 |
commit | 58cda9cc7fb79ca9df6746de7f9662bc08dc156a (patch) | |
tree | 1211600c2a5d3b5f81c435c6896618111a611720 /src/stores/UIStore.js | |
download | ferdium-app-58cda9cc7fb79ca9df6746de7f9662bc08dc156a.tar.gz ferdium-app-58cda9cc7fb79ca9df6746de7f9662bc08dc156a.tar.zst ferdium-app-58cda9cc7fb79ca9df6746de7f9662bc08dc156a.zip |
initial commit
Diffstat (limited to 'src/stores/UIStore.js')
-rw-r--r-- | src/stores/UIStore.js | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/stores/UIStore.js b/src/stores/UIStore.js new file mode 100644 index 000000000..cb45b88b5 --- /dev/null +++ b/src/stores/UIStore.js | |||
@@ -0,0 +1,34 @@ | |||
1 | import { action, observable } from 'mobx'; | ||
2 | |||
3 | import Store from './lib/Store'; | ||
4 | |||
5 | export default class UIStore extends Store { | ||
6 | @observable showServicesUpdatedInfoBar = false; | ||
7 | |||
8 | constructor(...args) { | ||
9 | super(...args); | ||
10 | |||
11 | // Register action handlers | ||
12 | this.actions.ui.openSettings.listen(this._openSettings.bind(this)); | ||
13 | this.actions.ui.closeSettings.listen(this._closeSettings.bind(this)); | ||
14 | this.actions.ui.toggleServiceUpdatedInfoBar.listen(this._toggleServiceUpdatedInfoBar.bind(this)); | ||
15 | } | ||
16 | |||
17 | // Actions | ||
18 | @action _openSettings({ path = '/settings' }) { | ||
19 | const settingsPath = path !== '/settings' ? `/settings/${path}` : path; | ||
20 | this.stores.router.push(settingsPath); | ||
21 | } | ||
22 | |||
23 | @action _closeSettings(): void { | ||
24 | this.stores.router.push('/'); | ||
25 | } | ||
26 | |||
27 | @action _toggleServiceUpdatedInfoBar({ visible }) { | ||
28 | let visibility = visible; | ||
29 | if (visibility === null) { | ||
30 | visibility = !this.showServicesUpdatedInfoBar; | ||
31 | } | ||
32 | this.showServicesUpdatedInfoBar = visibility; | ||
33 | } | ||
34 | } | ||