Welcome to mirror list, hosted at ThFree Co, Russian Federation.

autosave.js « utils « lib « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 023c336db02f4d9af90fd105dbde701c707ff7d8 (plain)
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
import { capitalizeFirstCharacter } from '~/lib/utils/text_utility';

export const clearDraft = autosaveKey => {
  try {
    window.localStorage.removeItem(`autosave/${autosaveKey}`);
  } catch (e) {
    // eslint-disable-next-line no-console
    console.error(e);
  }
};

export const getDraft = autosaveKey => {
  try {
    return window.localStorage.getItem(`autosave/${autosaveKey}`);
  } catch (e) {
    // eslint-disable-next-line no-console
    console.error(e);
    return null;
  }
};

export const updateDraft = (autosaveKey, text) => {
  try {
    window.localStorage.setItem(`autosave/${autosaveKey}`, text);
  } catch (e) {
    // eslint-disable-next-line no-console
    console.error(e);
  }
};

export const getDiscussionReplyKey = (noteableType, discussionId) =>
  ['Note', capitalizeFirstCharacter(noteableType), discussionId, 'Reply'].join('/');