aboutsummaryrefslogtreecommitdiffstats
path: root/src/features/nightlyBuilds/index.js
blob: 89bcb5cb3fd8311134732162e747a8060748c62e (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,
  };
}