Tracker: Refactor ViewOptions (#2228)

Signed-off-by: Dvinyanin Alexandr <dvinyanin.alexandr@gmail.com>
This commit is contained in:
Alex
2022-07-10 22:29:59 +07:00
committed by GitHub
parent 12da24f18c
commit 39b0cbda0e
13 changed files with 178 additions and 170 deletions
-21
View File
@@ -431,24 +431,3 @@ export function getActiveViewletId (): Ref<Viewlet> | null {
const key = makeViewletKey()
return localStorage.getItem(key) as Ref<Viewlet> | null
}
function makeViewOptionsKey (viewletId: Ref<Viewlet>): string {
const loc = getCurrentLocation()
loc.fragment = undefined
loc.query = undefined
return `viewOptions:${viewletId}:${locationToUrl(loc)}`
}
export function setViewOptions (viewletId: Ref<Viewlet>, options: string | null): void {
const key = makeViewOptionsKey(viewletId)
if (options !== null) {
localStorage.setItem(key, options)
} else {
localStorage.removeItem(key)
}
}
export function getViewOptions (viewletId: Ref<Viewlet>): string | null {
const key = makeViewOptionsKey(viewletId)
return localStorage.getItem(key)
}