aboutsummaryrefslogtreecommitdiffstats
path: root/src/features/nightlyBuilds/index.ts
blob: 14afbaf1b6b66cf0522e41cee82dabe8e51aae84 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { state as ModalState } from './store';

export { default as Component } from './Component';

const debug = require('debug')('Ferdi:feature:nightlyBuilds');

const state = ModalState;

export default function initialize() {
  debug('Initialize nightlyBuilds feature');

  function showModal() {
    state.isModalVisible = true;
  }

  function toggleFeature() {
    if (window['ferdi'].stores.settings.app.nightly) {
      window['ferdi'].actions.settings.update({
        type: 'app',
        data: {
          nightly: false,
        },
      });
      window['ferdi'].actions.user.update({
        userData: {
          nightly: false,
        },
      });
    } else {
      // We need to close the settings, otherwise the modal will be drawn under the settings window
      window['ferdi'].actions.ui.closeSettings();
      showModal();
    }
  }

  window['ferdi'].features.nightlyBuilds = {
    state,
    showModal,
    toggleFeature,
  };
}