logo

pleroma-fe

My custom branche(s) on git.pleroma.social/pleroma/pleroma-fe git clone https://hacktivis.me/git/pleroma-fe.git

main.js (3778B)


  1. import { createStore } from 'vuex'
  2. import 'custom-event-polyfill'
  3. import './lib/event_target_polyfill.js'
  4. import interfaceModule from './modules/interface.js'
  5. import instanceModule from './modules/instance.js'
  6. import statusesModule from './modules/statuses.js'
  7. import notificationsModule from './modules/notifications.js'
  8. import listsModule from './modules/lists.js'
  9. import usersModule from './modules/users.js'
  10. import apiModule from './modules/api.js'
  11. import configModule from './modules/config.js'
  12. import profileConfigModule from './modules/profileConfig.js'
  13. import serverSideStorageModule from './modules/serverSideStorage.js'
  14. import adminSettingsModule from './modules/adminSettings.js'
  15. import shoutModule from './modules/shout.js'
  16. import oauthModule from './modules/oauth.js'
  17. import authFlowModule from './modules/auth_flow.js'
  18. import mediaViewerModule from './modules/media_viewer.js'
  19. import oauthTokensModule from './modules/oauth_tokens.js'
  20. import reportsModule from './modules/reports.js'
  21. import pollsModule from './modules/polls.js'
  22. import postStatusModule from './modules/postStatus.js'
  23. import editStatusModule from './modules/editStatus.js'
  24. import statusHistoryModule from './modules/statusHistory.js'
  25. import chatsModule from './modules/chats.js'
  26. import announcementsModule from './modules/announcements.js'
  27. import { createI18n } from 'vue-i18n'
  28. import createPersistedState from './lib/persisted_state.js'
  29. import pushNotifications from './lib/push_notifications_plugin.js'
  30. import messages from './i18n/messages.js'
  31. import afterStoreSetup from './boot/after_store.js'
  32. const currentLocale = (window.navigator.language || 'en').split('-')[0]
  33. const i18n = createI18n({
  34. // By default, use the browser locale, we will update it if neccessary
  35. locale: 'en',
  36. fallbackLocale: 'en',
  37. messages: messages.default
  38. })
  39. messages.setLanguage(i18n.global, currentLocale)
  40. const persistedStateOptions = {
  41. paths: [
  42. 'serverSideStorage.cache',
  43. 'config',
  44. 'users.lastLoginName',
  45. 'oauth'
  46. ]
  47. };
  48. (async () => {
  49. let storageError = false
  50. const plugins = [pushNotifications]
  51. try {
  52. const persistedState = await createPersistedState(persistedStateOptions)
  53. plugins.push(persistedState)
  54. } catch (e) {
  55. console.error(e)
  56. storageError = true
  57. }
  58. const store = createStore({
  59. modules: {
  60. i18n: {
  61. getters: {
  62. i18n: () => i18n.global
  63. }
  64. },
  65. interface: interfaceModule,
  66. instance: instanceModule,
  67. // TODO refactor users/statuses modules, they depend on each other
  68. users: usersModule,
  69. statuses: statusesModule,
  70. notifications: notificationsModule,
  71. lists: listsModule,
  72. api: apiModule,
  73. config: configModule,
  74. profileConfig: profileConfigModule,
  75. serverSideStorage: serverSideStorageModule,
  76. adminSettings: adminSettingsModule,
  77. shout: shoutModule,
  78. oauth: oauthModule,
  79. authFlow: authFlowModule,
  80. mediaViewer: mediaViewerModule,
  81. oauthTokens: oauthTokensModule,
  82. reports: reportsModule,
  83. polls: pollsModule,
  84. postStatus: postStatusModule,
  85. editStatus: editStatusModule,
  86. statusHistory: statusHistoryModule,
  87. chats: chatsModule,
  88. announcements: announcementsModule
  89. },
  90. plugins,
  91. strict: false // Socket modifies itself, let's ignore this for now.
  92. // strict: process.env.NODE_ENV !== 'production'
  93. })
  94. if (storageError) {
  95. store.dispatch('pushGlobalNotice', { messageKey: 'errors.storage_unavailable', level: 'error' })
  96. }
  97. afterStoreSetup({ store, i18n })
  98. })()
  99. // These are inlined by webpack's DefinePlugin
  100. /* eslint-disable */
  101. window.___pleromafe_mode = process.env
  102. window.___pleromafe_commit_hash = COMMIT_HASH
  103. window.___pleromafe_dev_overrides = DEV_OVERRIDES