splashscreen is now smaller, big cleanup on aisle themes - removed a lot unnecessary sync/awaits and promises that were sequential anyway
This commit is contained in:
parent
6c5fc53789
commit
7550b8cbd2
10 changed files with 362 additions and 249 deletions
110
src/main.js
110
src/main.js
|
|
@ -48,6 +48,16 @@ const i18n = createI18n({
|
|||
|
||||
messages.setLanguage(i18n.global, currentLocale)
|
||||
|
||||
const splashError = (i18n, e) => {
|
||||
document.querySelector('#mascot').src = (Math.floor(Math.random() * 2) > 0)
|
||||
? '/static/pleromatan_orz_fox.png'
|
||||
: '/static/pleromatan_orz.png'
|
||||
document.querySelector('#mascot').classList.add('orz')
|
||||
document.querySelector('#throbber').classList.add('dead')
|
||||
document.querySelector('#status').textContent = i18n.global.t('splash.error')
|
||||
console.error('PleromaFE failed to initialize: ', e)
|
||||
}
|
||||
|
||||
const persistedStateOptions = {
|
||||
paths: [
|
||||
'serverSideStorage.cache',
|
||||
|
|
@ -58,57 +68,61 @@ const persistedStateOptions = {
|
|||
};
|
||||
|
||||
(async () => {
|
||||
let storageError = false
|
||||
const plugins = [pushNotifications]
|
||||
try {
|
||||
const persistedState = await createPersistedState(persistedStateOptions)
|
||||
plugins.push(persistedState)
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
storageError = true
|
||||
}
|
||||
document.querySelector('#status').removeAttribute('class')
|
||||
document.querySelector('#status').textContent = i18n.global.t('splash.loading')
|
||||
const store = createStore({
|
||||
modules: {
|
||||
i18n: {
|
||||
getters: {
|
||||
i18n: () => i18n.global
|
||||
}
|
||||
let storageError
|
||||
const plugins = [pushNotifications]
|
||||
try {
|
||||
const persistedState = await createPersistedState(persistedStateOptions)
|
||||
plugins.push(persistedState)
|
||||
} catch (e) {
|
||||
console.error('Storage error', e)
|
||||
storageError = e
|
||||
}
|
||||
document.querySelector('#status').removeAttribute('class')
|
||||
document.querySelector('#status').textContent = i18n.global.t('splash.loading')
|
||||
const store = createStore({
|
||||
modules: {
|
||||
i18n: {
|
||||
getters: {
|
||||
i18n: () => i18n.global
|
||||
}
|
||||
},
|
||||
interface: interfaceModule,
|
||||
instance: instanceModule,
|
||||
// TODO refactor users/statuses modules, they depend on each other
|
||||
users: usersModule,
|
||||
statuses: statusesModule,
|
||||
notifications: notificationsModule,
|
||||
lists: listsModule,
|
||||
api: apiModule,
|
||||
config: configModule,
|
||||
profileConfig: profileConfigModule,
|
||||
serverSideStorage: serverSideStorageModule,
|
||||
adminSettings: adminSettingsModule,
|
||||
shout: shoutModule,
|
||||
oauth: oauthModule,
|
||||
authFlow: authFlowModule,
|
||||
mediaViewer: mediaViewerModule,
|
||||
oauthTokens: oauthTokensModule,
|
||||
reports: reportsModule,
|
||||
polls: pollsModule,
|
||||
postStatus: postStatusModule,
|
||||
editStatus: editStatusModule,
|
||||
statusHistory: statusHistoryModule,
|
||||
chats: chatsModule,
|
||||
announcements: announcementsModule
|
||||
},
|
||||
interface: interfaceModule,
|
||||
instance: instanceModule,
|
||||
// TODO refactor users/statuses modules, they depend on each other
|
||||
users: usersModule,
|
||||
statuses: statusesModule,
|
||||
notifications: notificationsModule,
|
||||
lists: listsModule,
|
||||
api: apiModule,
|
||||
config: configModule,
|
||||
profileConfig: profileConfigModule,
|
||||
serverSideStorage: serverSideStorageModule,
|
||||
adminSettings: adminSettingsModule,
|
||||
shout: shoutModule,
|
||||
oauth: oauthModule,
|
||||
authFlow: authFlowModule,
|
||||
mediaViewer: mediaViewerModule,
|
||||
oauthTokens: oauthTokensModule,
|
||||
reports: reportsModule,
|
||||
polls: pollsModule,
|
||||
postStatus: postStatusModule,
|
||||
editStatus: editStatusModule,
|
||||
statusHistory: statusHistoryModule,
|
||||
chats: chatsModule,
|
||||
announcements: announcementsModule
|
||||
},
|
||||
plugins,
|
||||
strict: false // Socket modifies itself, let's ignore this for now.
|
||||
// strict: process.env.NODE_ENV !== 'production'
|
||||
})
|
||||
if (storageError) {
|
||||
store.dispatch('pushGlobalNotice', { messageKey: 'errors.storage_unavailable', level: 'error' })
|
||||
plugins,
|
||||
strict: false // Socket modifies itself, let's ignore this for now.
|
||||
// strict: process.env.NODE_ENV !== 'production'
|
||||
})
|
||||
if (storageError) {
|
||||
store.dispatch('pushGlobalNotice', { messageKey: 'errors.storage_unavailable', level: 'error' })
|
||||
}
|
||||
return await afterStoreSetup({ store, i18n })
|
||||
} catch (e) {
|
||||
splashError(i18n, e)
|
||||
}
|
||||
afterStoreSetup({ store, i18n })
|
||||
})()
|
||||
|
||||
// These are inlined by webpack's DefinePlugin
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue