working persistence in cookie world

This commit is contained in:
a 2022-07-03 11:05:10 -05:00
parent f206ce3bb2
commit e70d407ccb
2 changed files with 15 additions and 10 deletions

View File

@ -43,7 +43,7 @@ export const StoreStrSet = {
} }
export const StoreColSet = { export const StoreColSet = {
Murder: (s:ColumnSet):string=>Array.from(s).join(as), Murder: (s:ColumnSet):string=>Array.from(s.s.values()).join(as),
Revive: (s:string):ColumnSet=>new ColumnSet(s.split(as)) Revive: (s:string):ColumnSet=>new ColumnSet(s.split(as))
} }

View File

@ -14,19 +14,24 @@ const _defaultColumn:(ColumnInfo| ColumnName)[] = [
] ]
export const useStore = defineStore('state', { export const useStore = defineStore('state', {
state: ()=> { state: ()=> {
const last_table = getCookie(nameCookie("last_table")) let store = {
const last_screen = getCookie(nameCookie("last_screen"))
const last_columns = getCookie(nameCookie("last_columns"))?.split(",")
const last_tags = getCookie(nameCookie("last_tags"))?.split(",")
return {
invs: new Map() as Map<string,TricksterInventory>, invs: new Map() as Map<string,TricksterInventory>,
accounts: new Set() as Set<string>, accounts: new Set() as Set<string>,
activeTable: last_table ? last_table: "none", activeTable: "none",
screen: last_screen ? last_screen : "default", screen: "default",
columns: last_columns ? new ColumnSet([..._defaultColumn,...last_columns]) : new ColumnSet(_defaultColumn), columns:new ColumnSet(_defaultColumn),
tags: last_tags ? new ColumnSet(last_tags) : new ColumnSet(), tags: new ColumnSet(),
dirty: 0, dirty: 0,
} }
for(const [k, v] of Object.entries(StoreReviver)){
const coke = getCookie(nameCookie("last_"+k))
if(coke){
if((store[k as keyof StoreProps]) != undefined){
(store[k as keyof StoreProps] as any) = v.Revive(coke)
}
}
}
return store
} }
}) })