aboutsummaryrefslogtreecommitdiffstats
path: root/src/features/shareFranz/index.js
blob: 34475f6747765b50ae8ccf91beb22248ef40f890 (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
42
43
44
import { reaction } from 'mobx';
import ms from 'ms';
import { state as ModalState } from './store';
import { state as delayAppState } from '../delayApp';
import { planSelectionStore } from '../planSelection';

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

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

const state = ModalState;

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

  window.ferdi.features.shareFerdi = {
    state,
  };

  function showModal() {
    debug('Would have showed share window');

    // state.isModalVisible = true;
  }

  reaction(
    () => stores.user.isLoggedIn,
    () => {
      setTimeout(() => {
        if (stores.settings.stats.appStarts % 50 === 0 && !planSelectionStore.showPlanSelectionOverlay) {
          if (delayAppState.isDelayAppScreenVisible) {
            debug('Delaying share modal by 5 minutes');
            setTimeout(() => showModal(), ms('5m'));
          } else {
            showModal();
          }
        }
      }, ms('2s'));
    },
    {
      fireImmediately: true,
    },
  );
}