2021-04-24 07:56:00 -07:00
|
|
|
import { createStore } from 'vuex'
|
2016-10-26 10:03:55 -07:00
|
|
|
|
2020-01-23 12:53:48 -08:00
|
|
|
import 'custom-event-polyfill'
|
|
|
|
import './lib/event_target_polyfill.js'
|
|
|
|
|
2018-09-09 09:36:13 -07:00
|
|
|
import interfaceModule from './modules/interface.js'
|
2018-09-09 11:21:23 -07:00
|
|
|
import instanceModule from './modules/instance.js'
|
2016-10-27 09:03:25 -07:00
|
|
|
import statusesModule from './modules/statuses.js'
|
2022-08-06 07:26:43 -07:00
|
|
|
import listsModule from './modules/lists.js'
|
2016-10-27 09:03:25 -07:00
|
|
|
import usersModule from './modules/users.js'
|
2016-11-26 09:57:08 -08:00
|
|
|
import apiModule from './modules/api.js'
|
2017-02-14 13:21:23 -08:00
|
|
|
import configModule from './modules/config.js'
|
2022-02-22 13:31:40 -08:00
|
|
|
import serverSideConfigModule from './modules/serverSideConfig.js'
|
2022-08-03 15:56:52 -07:00
|
|
|
import serverSideStorageModule from './modules/serverSideStorage.js'
|
2020-08-03 16:44:35 -07:00
|
|
|
import shoutModule from './modules/shout.js'
|
2018-10-26 06:16:23 -07:00
|
|
|
import oauthModule from './modules/oauth.js'
|
2019-06-12 13:16:55 -07:00
|
|
|
import authFlowModule from './modules/auth_flow.js'
|
2019-01-14 09:23:13 -08:00
|
|
|
import mediaViewerModule from './modules/media_viewer.js'
|
2019-02-12 10:53:59 -08:00
|
|
|
import oauthTokensModule from './modules/oauth_tokens.js'
|
2019-03-19 01:53:11 -07:00
|
|
|
import reportsModule from './modules/reports.js'
|
2019-06-20 06:02:04 -07:00
|
|
|
import pollsModule from './modules/polls.js'
|
2019-09-19 10:27:37 -07:00
|
|
|
import postStatusModule from './modules/postStatus.js'
|
2020-05-07 06:10:53 -07:00
|
|
|
import chatsModule from './modules/chats.js'
|
2016-10-26 10:03:55 -07:00
|
|
|
|
2021-04-24 07:56:00 -07:00
|
|
|
import { createI18n } from 'vue-i18n'
|
2016-11-28 08:37:47 -08:00
|
|
|
|
2017-02-20 09:25:19 -08:00
|
|
|
import createPersistedState from './lib/persisted_state.js'
|
2018-12-25 05:43:18 -08:00
|
|
|
import pushNotifications from './lib/push_notifications_plugin.js'
|
2017-02-14 13:42:13 -08:00
|
|
|
|
2017-11-07 06:14:37 -08:00
|
|
|
import messages from './i18n/messages.js'
|
|
|
|
|
2018-10-26 06:16:23 -07:00
|
|
|
import afterStoreSetup from './boot/after_store.js'
|
|
|
|
|
2017-11-08 12:18:42 -08:00
|
|
|
const currentLocale = (window.navigator.language || 'en').split('-')[0]
|
|
|
|
|
2022-03-16 13:02:44 -07:00
|
|
|
const i18n = createI18n({
|
2018-08-25 03:12:33 -07:00
|
|
|
// By default, use the browser locale, we will update it if neccessary
|
2020-06-08 08:22:07 -07:00
|
|
|
locale: 'en',
|
2017-11-07 06:14:37 -08:00
|
|
|
fallbackLocale: 'en',
|
2020-06-08 08:22:07 -07:00
|
|
|
messages: messages.default
|
2017-11-07 06:14:37 -08:00
|
|
|
})
|
|
|
|
|
2020-06-08 08:22:07 -07:00
|
|
|
messages.setLanguage(i18n, currentLocale)
|
|
|
|
|
2018-10-26 06:16:23 -07:00
|
|
|
const persistedStateOptions = {
|
|
|
|
paths: [
|
2022-08-03 15:56:52 -07:00
|
|
|
'serverSideStorage.cache',
|
2018-10-26 06:16:23 -07:00
|
|
|
'config',
|
|
|
|
'users.lastLoginName',
|
|
|
|
'oauth'
|
|
|
|
]
|
2019-03-13 03:29:45 -07:00
|
|
|
};
|
2018-12-13 03:04:09 -08:00
|
|
|
|
2019-03-13 03:29:45 -07:00
|
|
|
(async () => {
|
2020-07-02 00:40:41 -07:00
|
|
|
let storageError = false
|
|
|
|
const plugins = [pushNotifications]
|
2020-07-01 09:15:28 -07:00
|
|
|
try {
|
2020-07-02 00:40:41 -07:00
|
|
|
const persistedState = await createPersistedState(persistedStateOptions)
|
|
|
|
plugins.push(persistedState)
|
2020-07-01 09:15:28 -07:00
|
|
|
} catch (e) {
|
|
|
|
console.error(e)
|
2020-07-02 00:40:41 -07:00
|
|
|
storageError = true
|
2020-07-01 09:15:28 -07:00
|
|
|
}
|
2021-04-24 07:56:00 -07:00
|
|
|
const store = createStore({
|
2018-10-26 06:16:23 -07:00
|
|
|
modules: {
|
2019-03-31 18:59:18 -07:00
|
|
|
i18n: {
|
|
|
|
getters: {
|
2021-04-25 03:30:18 -07:00
|
|
|
i18n: () => i18n.global
|
2019-03-31 18:59:18 -07:00
|
|
|
}
|
|
|
|
},
|
2018-10-26 06:16:23 -07:00
|
|
|
interface: interfaceModule,
|
|
|
|
instance: instanceModule,
|
2021-04-25 03:25:04 -07:00
|
|
|
// TODO refactor users/statuses modules, they depend on each other
|
2018-10-26 06:16:23 -07:00
|
|
|
users: usersModule,
|
2021-04-25 03:25:04 -07:00
|
|
|
statuses: statusesModule,
|
2022-08-06 07:26:43 -07:00
|
|
|
lists: listsModule,
|
2018-10-26 06:16:23 -07:00
|
|
|
api: apiModule,
|
|
|
|
config: configModule,
|
2022-02-22 13:31:40 -08:00
|
|
|
serverSideConfig: serverSideConfigModule,
|
2022-08-03 15:56:52 -07:00
|
|
|
serverSideStorage: serverSideStorageModule,
|
2020-08-03 16:44:35 -07:00
|
|
|
shout: shoutModule,
|
2019-01-14 09:23:13 -08:00
|
|
|
oauth: oauthModule,
|
2019-06-12 13:16:55 -07:00
|
|
|
authFlow: authFlowModule,
|
2019-02-12 10:53:59 -08:00
|
|
|
mediaViewer: mediaViewerModule,
|
2019-03-19 01:53:11 -07:00
|
|
|
oauthTokens: oauthTokensModule,
|
2019-06-20 06:02:04 -07:00
|
|
|
reports: reportsModule,
|
2019-09-19 10:27:37 -07:00
|
|
|
polls: pollsModule,
|
2020-05-07 06:10:53 -07:00
|
|
|
postStatus: postStatusModule,
|
|
|
|
chats: chatsModule
|
2018-10-26 06:16:23 -07:00
|
|
|
},
|
2020-07-02 00:40:41 -07:00
|
|
|
plugins,
|
2018-10-26 06:16:23 -07:00
|
|
|
strict: false // Socket modifies itself, let's ignore this for now.
|
|
|
|
// strict: process.env.NODE_ENV !== 'production'
|
2018-02-03 07:27:33 -08:00
|
|
|
})
|
2020-07-02 00:40:41 -07:00
|
|
|
if (storageError) {
|
|
|
|
store.dispatch('pushGlobalNotice', { messageKey: 'errors.storage_unavailable', level: 'error' })
|
|
|
|
}
|
2018-12-07 05:13:36 -08:00
|
|
|
afterStoreSetup({ store, i18n })
|
2019-03-13 03:29:45 -07:00
|
|
|
})()
|
2018-12-11 07:45:25 -08:00
|
|
|
|
|
|
|
// These are inlined by webpack's DefinePlugin
|
|
|
|
/* eslint-disable */
|
|
|
|
window.___pleromafe_mode = process.env
|
|
|
|
window.___pleromafe_commit_hash = COMMIT_HASH
|
|
|
|
window.___pleromafe_dev_overrides = DEV_OVERRIDES
|