diff options
author | Winnie Hellmann <winnie@gitlab.com> | 2019-02-26 15:02:17 +0100 |
---|---|---|
committer | Winnie Hellmann <winnie@gitlab.com> | 2019-03-12 12:03:30 +0100 |
commit | c75da766ae53eea50682f64c7101f8b77fb31a1c (patch) | |
tree | dae5111b6e4676452f438b7d42ae9d8fbf5cd514 /app | |
parent | e9d1393e8d68134e51819c72524cc84265a0acf8 (diff) | |
download | gitlab-ce-c75da766ae53eea50682f64c7101f8b77fb31a1c.tar.gz |
Add autosave utilities
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/lib/utils/autosave.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/app/assets/javascripts/lib/utils/autosave.js b/app/assets/javascripts/lib/utils/autosave.js new file mode 100644 index 00000000000..551035024a9 --- /dev/null +++ b/app/assets/javascripts/lib/utils/autosave.js @@ -0,0 +1,27 @@ +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); + } +}; |