* Add vue-rx, rxjs and lodash as dependencies * Added vue-rx plugin integration to nuxt config * Initial settings store implementation * Add babel plugin for private class properties to for Jest * Add DispatchingStore test spec * Initial settings code * Reactive Streams for fb current user and id token * Fix typo * Migrate index and graphql pages to the new store * Migrate network strategy to the new store * Fixed Section.vue errors * Fix getSettingSubject issue * Migrate fb settings reference in components to the new state system * Add typings for lodash as dev dependency * Load setting * Load initial sync setting values * Update proxy url * Add typescript support * Rewrite Settings store to TypeScript * Port Settings page to TypeScript as reference * Move all store migrations to a separate file * Delete test file for fb.js * Add ts-jest as dev dependency * Remove firebase-mock as dependency * Remove FRAME_COLORS_ENABLED settings value
37 lines
1012 B
TypeScript
37 lines
1012 B
TypeScript
import { settingsStore, bulkApplySettings, defaultSettings } from "./settings"
|
|
import clone from "lodash/clone"
|
|
import assign from "lodash/assign"
|
|
|
|
function checkAndMigrateOldSettings() {
|
|
// Don't do migration if the new settings object exists
|
|
if (window.localStorage.getItem("settings")) return
|
|
|
|
const vuexData = JSON.parse(window.localStorage.getItem("vuex") || "{}")
|
|
if (vuexData === {}) return
|
|
|
|
const settingsData = clone(defaultSettings)
|
|
assign(settingsData, vuexData.postwoman.settings)
|
|
|
|
window.localStorage.setItem("settings", JSON.stringify(settingsData))
|
|
}
|
|
|
|
function setupSettingsPersistence() {
|
|
const settingsData = JSON.parse(window.localStorage.getItem("settings") || "{}")
|
|
|
|
if (settingsData) {
|
|
bulkApplySettings(settingsData)
|
|
}
|
|
|
|
|
|
settingsStore.subject$
|
|
.subscribe(settings => {
|
|
window.localStorage.setItem("settings", JSON.stringify(settings))
|
|
})
|
|
}
|
|
|
|
export function setupLocalPersistence() {
|
|
checkAndMigrateOldSettings()
|
|
|
|
setupSettingsPersistence()
|
|
}
|