diff options
author | 2019-04-09 01:20:35 +0200 | |
---|---|---|
committer | 2019-04-09 01:20:35 +0200 | |
commit | 25fc276d5e3f754f915500e91229b8607febc478 (patch) | |
tree | 1875b74611d2cc7be8c6b040dae55ede89e51356 /src/features/settingsWS/index.js | |
parent | update strings (diff) | |
download | ferdium-app-25fc276d5e3f754f915500e91229b8607febc478.tar.gz ferdium-app-25fc276d5e3f754f915500e91229b8607febc478.tar.zst ferdium-app-25fc276d5e3f754f915500e91229b8607febc478.zip |
Add settings websocket
Diffstat (limited to 'src/features/settingsWS/index.js')
-rwxr-xr-x | src/features/settingsWS/index.js | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/features/settingsWS/index.js b/src/features/settingsWS/index.js new file mode 100755 index 000000000..1e268f184 --- /dev/null +++ b/src/features/settingsWS/index.js | |||
@@ -0,0 +1,35 @@ | |||
1 | import { reaction, runInAction } from 'mobx'; | ||
2 | import { SettingsWSStore } from './store'; | ||
3 | import state, { resetState } from './state'; | ||
4 | |||
5 | const debug = require('debug')('Franz:feature:settingsWS'); | ||
6 | |||
7 | let store = null; | ||
8 | |||
9 | export default function initAnnouncements(stores, actions) { | ||
10 | const { features } = stores; | ||
11 | |||
12 | // Toggle workspace feature | ||
13 | reaction( | ||
14 | () => ( | ||
15 | features.features.isSettingsWSEnabled | ||
16 | ), | ||
17 | (isEnabled) => { | ||
18 | if (isEnabled) { | ||
19 | debug('Initializing `settingsWS` feature'); | ||
20 | store = new SettingsWSStore(stores, null, actions, state); | ||
21 | store.initialize(); | ||
22 | runInAction(() => { state.isFeatureActive = true; }); | ||
23 | } else if (store) { | ||
24 | debug('Disabling `settingsWS` feature'); | ||
25 | runInAction(() => { state.isFeatureActive = false; }); | ||
26 | store.teardown(); | ||
27 | store = null; | ||
28 | resetState(); // Reset state to default | ||
29 | } | ||
30 | }, | ||
31 | { | ||
32 | fireImmediately: true, | ||
33 | }, | ||
34 | ); | ||
35 | } | ||