diff --git a/frontend/src/utils.js b/frontend/src/utils.js index a88188e..e5276d9 100644 --- a/frontend/src/utils.js +++ b/frontend/src/utils.js @@ -8,6 +8,7 @@ import relativeTime from 'dayjs/plugin/relativeTime'; dayjs.extend(relativeTime); const reEmail = /(.+?)@(.+?)/ig; +const prefKey = 'listmonk_pref'; const htmlEntities = { '&': '&', @@ -188,4 +189,23 @@ export default class Utils { return obj; }; + + getPref = (key) => { + if (localStorage.getItem(prefKey) === null) { + return null; + } + + const p = JSON.parse(localStorage.getItem(prefKey)); + return key in p ? p[key] : null; + }; + + setPref = (key, val) => { + let p = {}; + if (localStorage.getItem(prefKey) !== null) { + p = JSON.parse(localStorage.getItem(prefKey)); + } + + p[key] = val; + localStorage.setItem(prefKey, JSON.stringify(p)); + } } diff --git a/frontend/src/views/Settings.vue b/frontend/src/views/Settings.vue index 8709cd8..94793c4 100644 --- a/frontend/src/views/Settings.vue +++ b/frontend/src/views/Settings.vue @@ -21,7 +21,7 @@
- + @@ -98,6 +98,7 @@ export default Vue.extend({ // form is compared to detect changes. formCopy: '', form: {}, + tab: 0, }; }, @@ -237,7 +238,15 @@ export default Vue.extend({ }, mounted() { + this.tab = this.$utils.getPref('settings.tab') || 0; this.getSettings(); }, + + watch: { + // Capture contentType and body passed from the parent as props. + tab(t) { + this.$utils.setPref('settings.tab', t); + }, + }, });