<commit_before>/*
 * Copyright (C) 2015-2016 Actor LLC. <https://actor.im>
 */

import { dispatch } from '../dispatcher/ActorAppDispatcher';
import { ActionTypes } from '../constants/ActorAppConstants';

import ActorClient from '../utils/ActorClient';

import DraftStore from '../stores/DraftStore';

export default {
  loadDraft(peer) {
    const draft = ActorClient.loadDraft(peer);
    dispatch(ActionTypes.DRAFT_LOAD, { draft });
  },

  saveDraft(peer) {
    const draft = DraftStore.getDraft();
    ActorClient.saveDraft(peer, draft);
    dispatch(ActionTypes.DRAFT_SAVE, { draft });
  },

  changeDraft(draft) {
    dispatch(ActionTypes.DRAFT_CHANGE, { draft });
  }
};<commit_msg>fix(web): don't save or load draft if peer is null<commit_after>/*
 * Copyright (C) 2015-2016 Actor LLC. <https://actor.im>
 */

import { dispatch } from '../dispatcher/ActorAppDispatcher';
import { ActionTypes } from '../constants/ActorAppConstants';

import ActorClient from '../utils/ActorClient';

import DraftStore from '../stores/DraftStore';

export default {
  loadDraft(peer) {
    if (!peer) return null;

    const draft = ActorClient.loadDraft(peer);
    dispatch(ActionTypes.DRAFT_LOAD, { draft });
  },

  saveDraft(peer) {
    if (!peer) return null;

    const draft = DraftStore.getDraft();
    ActorClient.saveDraft(peer, draft);
    dispatch(ActionTypes.DRAFT_SAVE, { draft });
  },

  changeDraft(draft) {
    dispatch(ActionTypes.DRAFT_CHANGE, { draft });
  }
};
{'fraction_non_alphanumeric': 0.14819850441876276, 'fraction_numerical': 0.010876954452753228, 'mean_word_length': 3.9066666666666667, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '6535653', 'n_tokens_mistral': 499, 'n_tokens_neox': 467, 'n_words': 101}