diff options
Diffstat (limited to 'src/features/nightlyBuilds/index.js')
-rw-r--r-- | src/features/nightlyBuilds/index.js | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/features/nightlyBuilds/index.js b/src/features/nightlyBuilds/index.js new file mode 100644 index 000000000..34fe37d4d --- /dev/null +++ b/src/features/nightlyBuilds/index.js | |||
@@ -0,0 +1,45 @@ | |||
1 | import { observable } from 'mobx'; | ||
2 | |||
3 | export { default as Component } from './Component'; | ||
4 | |||
5 | const debug = require('debug')('Ferdi:feature:nightlyBuilds'); | ||
6 | |||
7 | const defaultState = { | ||
8 | isModalVisible: false, | ||
9 | }; | ||
10 | |||
11 | export const state = observable(defaultState); | ||
12 | |||
13 | export default function initialize() { | ||
14 | debug('Initialize nightlyBuilds feature'); | ||
15 | |||
16 | function showModal() { | ||
17 | state.isModalVisible = true; | ||
18 | } | ||
19 | |||
20 | function toggleFeature() { | ||
21 | if (window.ferdi.stores.settings.app.nightly) { | ||
22 | window.ferdi.actions.settings.update({ | ||
23 | type: 'app', | ||
24 | data: { | ||
25 | nightly: false, | ||
26 | }, | ||
27 | }); | ||
28 | window.ferdi.actions.user.update({ | ||
29 | userData: { | ||
30 | nightly: false, | ||
31 | }, | ||
32 | }); | ||
33 | } else { | ||
34 | // We need to close the settings, otherwise the modal will be drawn under the settings window | ||
35 | window.ferdi.actions.ui.closeSettings(); | ||
36 | showModal(); | ||
37 | } | ||
38 | } | ||
39 | |||
40 | window.ferdi.features.nightlyBuilds = { | ||
41 | state, | ||
42 | showModal, | ||
43 | toggleFeature, | ||
44 | }; | ||
45 | } | ||