<commit_before>import { types, getEnv } from 'mobx-state-tree';
import * as actionTypes from '../actionTypes';

export default types
  .model('Sticky')
  .props({
    isOpen: false,
    timeout: null,
    closedByUser: false,
  })
  .actions(self => {
    const { store, isClient } = getEnv(self);
    return {
      [actionTypes.STICKY_HAS_SHOWN]: ({ timeout }) => {
        self.isOpen = true;
        self.timeout = timeout;
      },
      [actionTypes.STICKY_HAS_HIDDEN]: () => {
        self.isOpen = false;
        self.timeout = null;
        self.closedByUser = true;
      },
      [actionTypes.STICKY_UPDATE_TIMEOUT]: ({ timeout }) => {
        self.timeout = timeout;
      },
      afterCreate: () => {
        if (isClient) {
          if (store)
            store.subscribe(() => {
              const action = store.getState().lastAction;

              if (self[action.type]) {
                self[action.type](action);
              }
            });
        }
      },
    };<commit_msg>Fixes in sticky's store<commit_after>import { types, getEnv } from 'mobx-state-tree';
import * as actionTypes from '../actionTypes';

export default types
  .model('Sticky')
  .props({
    isOpen: false,
    timeout: types.maybe(types.number),
    closedByUser: false,
  })
  .actions(self => {
    const { store, isClient } = getEnv(self);
    return {
      [actionTypes.STICKY_HAS_SHOWN]: ({ timeout }) => {
        self.isOpen = true;
        self.timeout = timeout;
      },
      [actionTypes.STICKY_HAS_HIDDEN]: ({ closedByUser }) => {
        self.isOpen = false;
        self.timeout = null;
        self.closedByUser = closedByUser;
      },
      [actionTypes.STICKY_UPDATE_TIMEOUT]: ({ timeout }) => {
        self.timeout = timeout;
      },
      afterCreate: () => {
        if (isClient) {
          if (store) {
            store.subscribe(() => {
              const action = store.getState().lastAction;

              if (self[action.type]) {
                self[action.type](action);
              }
            });
          }
        }
      },
    };
{'fraction_non_alphanumeric': 0.14560307544449783, 'fraction_numerical': 0.0, 'mean_word_length': 1.828804347826087, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '920278', 'n_tokens_mistral': 636, 'n_tokens_neox': 627, 'n_words': 116}