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