diff options
author | 2019-03-12 21:36:10 +0100 | |
---|---|---|
committer | 2019-03-12 21:37:33 +0100 | |
commit | 6fb07bcb716af76ec2e96345f37624d12d0d1af0 (patch) | |
tree | 276191a782dc1d44f78331e548e43ff71758baca /src/features/announcements/index.js | |
parent | refactor server api even more (diff) | |
download | ferdium-app-6fb07bcb716af76ec2e96345f37624d12d0d1af0.tar.gz ferdium-app-6fb07bcb716af76ec2e96345f37624d12d0d1af0.tar.zst ferdium-app-6fb07bcb716af76ec2e96345f37624d12d0d1af0.zip |
implements basic release announcement feature
Diffstat (limited to 'src/features/announcements/index.js')
-rw-r--r-- | src/features/announcements/index.js | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/features/announcements/index.js b/src/features/announcements/index.js new file mode 100644 index 000000000..5ea74e0af --- /dev/null +++ b/src/features/announcements/index.js | |||
@@ -0,0 +1,37 @@ | |||
1 | import { reaction, runInAction } from 'mobx'; | ||
2 | import { AnnouncementsStore } from './store'; | ||
3 | import api from './api'; | ||
4 | import state, { resetState } from './state'; | ||
5 | |||
6 | const debug = require('debug')('Franz:feature:announcements'); | ||
7 | |||
8 | let store = null; | ||
9 | |||
10 | export default function initAnnouncements(stores, actions) { | ||
11 | // const { features } = stores; | ||
12 | |||
13 | // Toggle workspace feature | ||
14 | reaction( | ||
15 | () => ( | ||
16 | true | ||
17 | // features.features.isAnnouncementsEnabled | ||
18 | ), | ||
19 | (isEnabled) => { | ||
20 | if (isEnabled) { | ||
21 | debug('Initializing `announcements` feature'); | ||
22 | store = new AnnouncementsStore(stores, api, actions, state); | ||
23 | store.initialize(); | ||
24 | runInAction(() => { state.isFeatureActive = true; }); | ||
25 | } else if (store) { | ||
26 | debug('Disabling `announcements` feature'); | ||
27 | runInAction(() => { state.isFeatureActive = false; }); | ||
28 | store.teardown(); | ||
29 | store = null; | ||
30 | resetState(); // Reset state to default | ||
31 | } | ||
32 | }, | ||
33 | { | ||
34 | fireImmediately: true, | ||
35 | }, | ||
36 | ); | ||
37 | } | ||