after_store cleanup
This commit is contained in:
parent
ab6ac91072
commit
62e8bc58c6
1 changed files with 15 additions and 14 deletions
|
|
@ -70,7 +70,7 @@ const decodeUTF8Base64 = (data) => {
|
|||
|
||||
const preloadFetch = async (request) => {
|
||||
const data = parsedInitialResults()
|
||||
if (!data || !data[request]) {
|
||||
if (data?.[request]) {
|
||||
return window.fetch(request)
|
||||
}
|
||||
const decoded = decodeUTF8Base64(data[request])
|
||||
|
|
@ -170,9 +170,9 @@ const setSettings = async ({ apiConfig, staticConfig, store }) => {
|
|||
let config = {}
|
||||
if (overrides.staticConfigPreference && env === 'development') {
|
||||
console.warn('OVERRIDING API CONFIG WITH STATIC CONFIG')
|
||||
config = Object.assign({}, apiConfig, staticConfig)
|
||||
config = { ...apiConfig, ...staticConfig }
|
||||
} else {
|
||||
config = Object.assign({}, staticConfig, apiConfig)
|
||||
config = { ...staticConfig, ...apiConfig }
|
||||
}
|
||||
|
||||
Object.keys(INSTANCE_IDENTITY_DEFAULT_DEFINITIONS).forEach((source) => {
|
||||
|
|
@ -443,7 +443,7 @@ const getNodeInfo = async ({ store }) => {
|
|||
const setConfig = async ({ store }) => {
|
||||
// apiConfig, staticConfig
|
||||
const configInfos = await Promise.all([
|
||||
getBackendProvidedConfig({ store }),
|
||||
getBackendProvidedConfig(),
|
||||
getStaticConfig(),
|
||||
])
|
||||
const apiConfig = configInfos[0]
|
||||
|
|
@ -457,7 +457,7 @@ const checkOAuthToken = async ({ store }) => {
|
|||
if (oauth.userToken) {
|
||||
return store.dispatch('loginUser', oauth.userToken)
|
||||
}
|
||||
return Promise.resolve()
|
||||
return
|
||||
}
|
||||
|
||||
const afterStoreSetup = async ({ pinia, store, storageError, i18n }) => {
|
||||
|
|
@ -485,7 +485,7 @@ const afterStoreSetup = async ({ pinia, store, storageError, i18n }) => {
|
|||
if (process.env.NODE_ENV === 'development') {
|
||||
// do some checks to avoid common errors
|
||||
if (!Object.keys(allStores).length) {
|
||||
throw new Error(
|
||||
throw new TypeError(
|
||||
'No stores are available. Check the code in src/boot/after_store.js',
|
||||
)
|
||||
}
|
||||
|
|
@ -495,7 +495,7 @@ const afterStoreSetup = async ({ pinia, store, storageError, i18n }) => {
|
|||
const isStoreName = (name) => name.startsWith('use')
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
if (Object.keys(mod).filter(isStoreName).length !== 1) {
|
||||
throw new Error(
|
||||
throw new TypeError(
|
||||
'Each store file must export exactly one store as a named export. Check your code in src/stores/',
|
||||
)
|
||||
}
|
||||
|
|
@ -504,13 +504,13 @@ const afterStoreSetup = async ({ pinia, store, storageError, i18n }) => {
|
|||
if (storeFuncName && typeof mod[storeFuncName] === 'function') {
|
||||
const p = mod[storeFuncName]().$persistLoaded
|
||||
if (!(p instanceof Promise)) {
|
||||
throw new Error(
|
||||
throw new TypeError(
|
||||
`${name} store's $persistLoaded is not a Promise. The persist plugin is not applied.`,
|
||||
)
|
||||
}
|
||||
await p
|
||||
} else {
|
||||
throw new Error(
|
||||
throw new TypeError(
|
||||
`Store module ${name} does not export a 'use...' function`,
|
||||
)
|
||||
}
|
||||
|
|
@ -518,14 +518,15 @@ const afterStoreSetup = async ({ pinia, store, storageError, i18n }) => {
|
|||
)
|
||||
}
|
||||
|
||||
let newStorageError
|
||||
try {
|
||||
await waitForAllStoresToLoad()
|
||||
} catch (e) {
|
||||
console.error('Cannot load stores:', e)
|
||||
storageError = e
|
||||
newStorageError = e
|
||||
}
|
||||
|
||||
if (storageError) {
|
||||
if (storageError || newStorageError) {
|
||||
useInterfaceStore().pushGlobalNotice({
|
||||
messageKey: 'errors.storage_unavailable',
|
||||
level: 'error',
|
||||
|
|
@ -561,7 +562,7 @@ const afterStoreSetup = async ({ pinia, store, storageError, i18n }) => {
|
|||
})
|
||||
} catch (e) {
|
||||
window.splashError(e)
|
||||
return Promise.reject(e)
|
||||
throw e
|
||||
}
|
||||
|
||||
applyStyleConfig(useMergedConfigStore().mergedConfig, i18n.global)
|
||||
|
|
@ -573,7 +574,7 @@ const afterStoreSetup = async ({ pinia, store, storageError, i18n }) => {
|
|||
getInstancePanel({ store }),
|
||||
getNodeInfo({ store }),
|
||||
getInstanceConfig({ store }),
|
||||
]).catch((e) => Promise.reject(e))
|
||||
])
|
||||
|
||||
getTOS({ store })
|
||||
getStickers({ store })
|
||||
|
|
@ -583,7 +584,7 @@ const afterStoreSetup = async ({ pinia, store, storageError, i18n }) => {
|
|||
routes: routes(store),
|
||||
scrollBehavior: (to, _from, savedPosition) => {
|
||||
if (to.matched.some((m) => m.meta.dontScroll)) {
|
||||
return false
|
||||
return {}
|
||||
}
|
||||
return savedPosition || { left: 0, top: 0 }
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue