mirror of
https://akkoma.dev/AkkomaGang/akkoma-fe.git
synced 2024-11-11 02:59:13 +00:00
Set state to loaded if it crashes while loading.
This commit is contained in:
parent
1ea19dcf1d
commit
40b607bdea
1 changed files with 16 additions and 11 deletions
|
@ -38,19 +38,24 @@ export default function createPersistedState ({
|
|||
} = {}) {
|
||||
return store => {
|
||||
getState(key, storage).then((savedState) => {
|
||||
if (typeof savedState === 'object') {
|
||||
// build user cache
|
||||
const usersState = savedState.users || {}
|
||||
usersState.usersObject = {}
|
||||
const users = usersState.users || []
|
||||
each(users, (user) => { usersState.usersObject[user.id] = user })
|
||||
savedState.users = usersState
|
||||
try {
|
||||
if (typeof savedState === 'object') {
|
||||
// build user cache
|
||||
const usersState = savedState.users || {}
|
||||
usersState.usersObject = {}
|
||||
const users = usersState.users || []
|
||||
each(users, (user) => { usersState.usersObject[user.id] = user })
|
||||
savedState.users = usersState
|
||||
|
||||
store.replaceState(
|
||||
merge({}, store.state, savedState)
|
||||
)
|
||||
store.replaceState(
|
||||
merge({}, store.state, savedState)
|
||||
)
|
||||
}
|
||||
loaded = true
|
||||
} catch (e) {
|
||||
console.log("Couldn't load state")
|
||||
loaded = true
|
||||
}
|
||||
loaded = true
|
||||
})
|
||||
|
||||
subscriber(store)((mutation, state) => {
|
||||
|
|
Loading…
Reference in a new issue