2019-03-04 16:00:18 -05:00
|
|
|
import { capitalizeFirstCharacter } from '~/lib/utils/text_utility';
|
|
|
|
|
2020-12-23 19:10:25 -05:00
|
|
|
export const clearDraft = (autosaveKey) => {
|
2019-02-26 09:02:17 -05:00
|
|
|
try {
|
|
|
|
window.localStorage.removeItem(`autosave/${autosaveKey}`);
|
|
|
|
} catch (e) {
|
|
|
|
// eslint-disable-next-line no-console
|
|
|
|
console.error(e);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-12-23 19:10:25 -05:00
|
|
|
export const getDraft = (autosaveKey) => {
|
2019-02-26 09:02:17 -05:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
};
|
2019-03-04 16:00:18 -05:00
|
|
|
|
|
|
|
export const getDiscussionReplyKey = (noteableType, discussionId) =>
|
2020-03-18 11:09:45 -04:00
|
|
|
/* eslint-disable-next-line @gitlab/require-i18n-strings */
|
2019-03-04 16:00:18 -05:00
|
|
|
['Note', capitalizeFirstCharacter(noteableType), discussionId, 'Reply'].join('/');
|