rename scene classes for clarity (#1409)
* rename for clarity * typo * make coverage happ+ somewhat pointless since we don't use coverage because its not complete with both vitest and playwright * local storage issue * fmt * fix
This commit is contained in:
@ -99,7 +99,7 @@ class KclManager {
|
||||
})
|
||||
})
|
||||
} else {
|
||||
localStorage?.setItem(PERSIST_CODE_TOKEN, code)
|
||||
safteLSSetItem(PERSIST_CODE_TOKEN, code)
|
||||
}
|
||||
}
|
||||
|
||||
@ -154,16 +154,16 @@ class KclManager {
|
||||
this.code = ''
|
||||
return
|
||||
}
|
||||
const storedCode = localStorage.getItem(PERSIST_CODE_TOKEN)
|
||||
const storedCode = safeLSGetItem(PERSIST_CODE_TOKEN) || ''
|
||||
// TODO #819 remove zustand persistence logic in a few months
|
||||
// short term migration, shouldn't make a difference for tauri app users
|
||||
// anyway since that's filesystem based.
|
||||
const zustandStore = JSON.parse(localStorage.getItem('store') || '{}')
|
||||
const zustandStore = JSON.parse(safeLSGetItem('store') || '{}')
|
||||
if (storedCode === null && zustandStore?.state?.code) {
|
||||
this.code = zustandStore.state.code
|
||||
localStorage.setItem(PERSIST_CODE_TOKEN, this._code)
|
||||
safteLSSetItem(PERSIST_CODE_TOKEN, this._code)
|
||||
zustandStore.state.code = ''
|
||||
localStorage.setItem('store', JSON.stringify(zustandStore))
|
||||
safteLSSetItem('store', JSON.stringify(zustandStore))
|
||||
} else if (storedCode === null) {
|
||||
this.code = bracket
|
||||
} else {
|
||||
@ -457,3 +457,13 @@ export function KclContextProvider({
|
||||
</KclContext.Provider>
|
||||
)
|
||||
}
|
||||
|
||||
function safeLSGetItem(key: string) {
|
||||
if (typeof window === 'undefined') return null
|
||||
return localStorage?.getItem(key)
|
||||
}
|
||||
|
||||
function safteLSSetItem(key: string, value: string) {
|
||||
if (typeof window === 'undefined') return
|
||||
localStorage?.setItem(key, value)
|
||||
}
|
||||
|
Reference in New Issue
Block a user