2016-10-26 16:46:32 +02:00
|
|
|
import Vue from 'vue'
|
2016-10-26 19:03:55 +02:00
|
|
|
import VueRouter from 'vue-router'
|
|
|
|
import Vuex from 'vuex'
|
|
|
|
|
2020-01-23 21:53:48 +01:00
|
|
|
import 'custom-event-polyfill'
|
|
|
|
import './lib/event_target_polyfill.js'
|
|
|
|
|
2018-09-09 18:36:13 +02:00
|
|
|
import interfaceModule from './modules/interface.js'
|
2018-09-09 20:21:23 +02:00
|
|
|
import instanceModule from './modules/instance.js'
|
2016-10-27 18:03:25 +02:00
|
|
|
import statusesModule from './modules/statuses.js'
|
|
|
|
import usersModule from './modules/users.js'
|
2016-11-26 18:57:08 +01:00
|
|
|
import apiModule from './modules/api.js'
|
2017-02-14 22:21:23 +01:00
|
|
|
import configModule from './modules/config.js'
|
2020-08-04 01:44:35 +02:00
|
|
|
import shoutModule from './modules/shout.js'
|
2018-10-26 15:16:23 +02:00
|
|
|
import oauthModule from './modules/oauth.js'
|
2019-06-12 22:16:55 +02:00
|
|
|
import authFlowModule from './modules/auth_flow.js'
|
2019-01-14 18:23:13 +01:00
|
|
|
import mediaViewerModule from './modules/media_viewer.js'
|
2019-02-12 19:53:59 +01:00
|
|
|
import oauthTokensModule from './modules/oauth_tokens.js'
|
2019-03-19 09:53:11 +01:00
|
|
|
import reportsModule from './modules/reports.js'
|
2019-06-20 15:02:04 +02:00
|
|
|
import pollsModule from './modules/polls.js'
|
2019-09-19 19:27:37 +02:00
|
|
|
import postStatusModule from './modules/postStatus.js'
|
2020-05-07 15:10:53 +02:00
|
|
|
import chatsModule from './modules/chats.js'
|
2016-10-26 19:03:55 +02:00
|
|
|
|
2017-11-07 15:14:37 +01:00
|
|
|
import VueI18n from 'vue-i18n'
|
2016-11-28 17:37:47 +01:00
|
|
|
|
2017-02-20 18:25:19 +01:00
|
|
|
import createPersistedState from './lib/persisted_state.js'
|
2018-12-25 14:43:18 +01:00
|
|
|
import pushNotifications from './lib/push_notifications_plugin.js'
|
2017-02-14 22:42:13 +01:00
|
|
|
|
2017-11-07 15:14:37 +01:00
|
|
|
import messages from './i18n/messages.js'
|
|
|
|
|
2019-04-02 19:18:36 +02:00
|
|
|
import VueClickOutside from 'v-click-outside'
|
2019-05-20 22:19:59 +02:00
|
|
|
import PortalVue from 'portal-vue'
|
2019-07-19 18:27:03 +02:00
|
|
|
import VBodyScrollLock from './directives/body_scroll_lock'
|
2018-01-26 15:11:34 +01:00
|
|
|
|
2020-10-19 21:35:46 +02:00
|
|
|
import { FontAwesomeIcon, FontAwesomeLayers } from '@fortawesome/vue-fontawesome'
|
2020-10-19 18:38:49 +02:00
|
|
|
|
2018-10-26 15:16:23 +02:00
|
|
|
import afterStoreSetup from './boot/after_store.js'
|
|
|
|
|
2017-11-08 21:18:42 +01:00
|
|
|
const currentLocale = (window.navigator.language || 'en').split('-')[0]
|
|
|
|
|
2016-10-26 19:03:55 +02:00
|
|
|
Vue.use(Vuex)
|
|
|
|
Vue.use(VueRouter)
|
2017-11-07 15:14:37 +01:00
|
|
|
Vue.use(VueI18n)
|
2019-04-02 19:18:36 +02:00
|
|
|
Vue.use(VueClickOutside)
|
2019-05-20 22:19:59 +02:00
|
|
|
Vue.use(PortalVue)
|
2019-07-19 18:27:03 +02:00
|
|
|
Vue.use(VBodyScrollLock)
|
2016-10-26 19:03:55 +02:00
|
|
|
|
2020-10-19 18:38:49 +02:00
|
|
|
Vue.component('FAIcon', FontAwesomeIcon)
|
2020-10-19 21:35:46 +02:00
|
|
|
Vue.component('FALayers', FontAwesomeLayers)
|
2020-10-19 18:38:49 +02:00
|
|
|
|
2017-11-07 15:14:37 +01:00
|
|
|
const i18n = new VueI18n({
|
2018-08-25 12:12:33 +02:00
|
|
|
// By default, use the browser locale, we will update it if neccessary
|
2020-06-08 17:22:07 +02:00
|
|
|
locale: 'en',
|
2017-11-07 15:14:37 +01:00
|
|
|
fallbackLocale: 'en',
|
2020-06-08 17:22:07 +02:00
|
|
|
messages: messages.default
|
2017-11-07 15:14:37 +01:00
|
|
|
})
|
|
|
|
|
2020-06-08 17:22:07 +02:00
|
|
|
messages.setLanguage(i18n, currentLocale)
|
|
|
|
|
2018-10-26 15:16:23 +02:00
|
|
|
const persistedStateOptions = {
|
|
|
|
paths: [
|
|
|
|
'config',
|
|
|
|
'users.lastLoginName',
|
|
|
|
'oauth'
|
|
|
|
]
|
2019-03-13 11:29:45 +01:00
|
|
|
};
|
2018-12-13 12:04:09 +01:00
|
|
|
|
2019-03-13 11:29:45 +01:00
|
|
|
(async () => {
|
2020-07-02 09:40:41 +02:00
|
|
|
let storageError = false
|
|
|
|
const plugins = [pushNotifications]
|
2020-07-01 18:15:28 +02:00
|
|
|
try {
|
2020-07-02 09:40:41 +02:00
|
|
|
const persistedState = await createPersistedState(persistedStateOptions)
|
|
|
|
plugins.push(persistedState)
|
2020-07-01 18:15:28 +02:00
|
|
|
} catch (e) {
|
|
|
|
console.error(e)
|
2020-07-02 09:40:41 +02:00
|
|
|
storageError = true
|
2020-07-01 18:15:28 +02:00
|
|
|
}
|
2018-10-26 15:16:23 +02:00
|
|
|
const store = new Vuex.Store({
|
|
|
|
modules: {
|
2019-04-01 03:59:18 +02:00
|
|
|
i18n: {
|
|
|
|
getters: {
|
|
|
|
i18n: () => i18n
|
|
|
|
}
|
|
|
|
},
|
2018-10-26 15:16:23 +02:00
|
|
|
interface: interfaceModule,
|
|
|
|
instance: instanceModule,
|
|
|
|
statuses: statusesModule,
|
|
|
|
users: usersModule,
|
|
|
|
api: apiModule,
|
|
|
|
config: configModule,
|
2020-08-04 01:44:35 +02:00
|
|
|
shout: shoutModule,
|
2019-01-14 18:23:13 +01:00
|
|
|
oauth: oauthModule,
|
2019-06-12 22:16:55 +02:00
|
|
|
authFlow: authFlowModule,
|
2019-02-12 19:53:59 +01:00
|
|
|
mediaViewer: mediaViewerModule,
|
2019-03-19 09:53:11 +01:00
|
|
|
oauthTokens: oauthTokensModule,
|
2019-06-20 15:02:04 +02:00
|
|
|
reports: reportsModule,
|
2019-09-19 19:27:37 +02:00
|
|
|
polls: pollsModule,
|
2020-05-07 15:10:53 +02:00
|
|
|
postStatus: postStatusModule,
|
|
|
|
chats: chatsModule
|
2018-10-26 15:16:23 +02:00
|
|
|
},
|
2020-07-02 09:40:41 +02:00
|
|
|
plugins,
|
2018-10-26 15:16:23 +02:00
|
|
|
strict: false // Socket modifies itself, let's ignore this for now.
|
|
|
|
// strict: process.env.NODE_ENV !== 'production'
|
2018-02-03 16:27:33 +01:00
|
|
|
})
|
2020-07-02 09:40:41 +02:00
|
|
|
if (storageError) {
|
|
|
|
store.dispatch('pushGlobalNotice', { messageKey: 'errors.storage_unavailable', level: 'error' })
|
|
|
|
}
|
2018-12-07 14:13:36 +01:00
|
|
|
afterStoreSetup({ store, i18n })
|
2019-03-13 11:29:45 +01:00
|
|
|
})()
|
2018-12-11 16:45:25 +01: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
|