diff options
author | 2019-04-16 14:17:31 +0200 | |
---|---|---|
committer | 2019-04-16 14:17:31 +0200 | |
commit | e6535eb6d3b8700335076950a8ca531be8cde175 (patch) | |
tree | 0cf45078f9a0135f11d2c37fbc272b5657087742 /src/features/settingsWS/index.js | |
parent | fix feature store test (diff) | |
download | ferdium-app-e6535eb6d3b8700335076950a8ca531be8cde175.tar.gz ferdium-app-e6535eb6d3b8700335076950a8ca531be8cde175.tar.zst ferdium-app-e6535eb6d3b8700335076950a8ca531be8cde175.zip |
Refactor settingsWS Store to new FeatureStore
Diffstat (limited to 'src/features/settingsWS/index.js')
-rwxr-xr-x | src/features/settingsWS/index.js | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/src/features/settingsWS/index.js b/src/features/settingsWS/index.js index 4049ae814..2064d2973 100755 --- a/src/features/settingsWS/index.js +++ b/src/features/settingsWS/index.js | |||
@@ -1,10 +1,9 @@ | |||
1 | import { reaction, runInAction } from 'mobx'; | 1 | import { reaction } from 'mobx'; |
2 | import { SettingsWSStore } from './store'; | 2 | import { SettingsWSStore } from './store'; |
3 | import state, { resetState } from './state'; | ||
4 | 3 | ||
5 | const debug = require('debug')('Franz:feature:settingsWS'); | 4 | const debug = require('debug')('Franz:feature:settingsWS'); |
6 | 5 | ||
7 | let store = null; | 6 | export const settingsStore = new SettingsWSStore(); |
8 | 7 | ||
9 | export default function initSettingsWebSocket(stores, actions) { | 8 | export default function initSettingsWebSocket(stores, actions) { |
10 | const { features } = stores; | 9 | const { features } = stores; |
@@ -17,15 +16,10 @@ export default function initSettingsWebSocket(stores, actions) { | |||
17 | (isEnabled) => { | 16 | (isEnabled) => { |
18 | if (isEnabled) { | 17 | if (isEnabled) { |
19 | debug('Initializing `settingsWS` feature'); | 18 | debug('Initializing `settingsWS` feature'); |
20 | store = new SettingsWSStore(stores, null, actions, state); | 19 | settingsStore.start(stores, actions); |
21 | store.initialize(); | 20 | } else if (settingsStore) { |
22 | runInAction(() => { state.isFeatureActive = true; }); | ||
23 | } else if (store) { | ||
24 | debug('Disabling `settingsWS` feature'); | 21 | debug('Disabling `settingsWS` feature'); |
25 | runInAction(() => { state.isFeatureActive = false; }); | 22 | settingsStore.stop(); |
26 | store.teardown(); | ||
27 | store = null; | ||
28 | resetState(); // Reset state to default | ||
29 | } | 23 | } |
30 | }, | 24 | }, |
31 | { | 25 | { |