pleroma-fe/src/App.js

136 lines
5.3 KiB
JavaScript
Raw Permalink Normal View History

2016-10-27 18:01:48 +02:00
import UserPanel from './components/user_panel/user_panel.vue'
2016-11-06 20:11:23 +01:00
import NavPanel from './components/nav_panel/nav_panel.vue'
2018-02-03 16:27:33 +01:00
import InstanceSpecificPanel from './components/instance_specific_panel/instance_specific_panel.vue'
2018-09-03 08:57:22 +02:00
import FeaturesPanel from './components/features_panel/features_panel.vue'
2018-09-03 07:43:10 +02:00
import WhoToFollowPanel from './components/who_to_follow_panel/who_to_follow_panel.vue'
import ShoutPanel from './components/shout_panel/shout_panel.vue'
import MediaModal from './components/media_modal/media_modal.vue'
import SideDrawer from './components/side_drawer/side_drawer.vue'
2019-09-19 19:59:34 +02:00
import MobilePostStatusButton from './components/mobile_post_status_button/mobile_post_status_button.vue'
import MobileNav from './components/mobile_nav/mobile_nav.vue'
import DesktopNav from './components/desktop_nav/desktop_nav.vue'
2019-03-19 09:53:11 +01:00
import UserReportingModal from './components/user_reporting_modal/user_reporting_modal.vue'
2022-06-08 05:31:48 +02:00
import EditStatusModal from './components/edit_status_modal/edit_status_modal.vue'
import PostStatusModal from './components/post_status_modal/post_status_modal.vue'
import StatusHistoryModal from './components/status_history_modal/status_history_modal.vue'
import GlobalNoticeList from './components/global_notice_list/global_notice_list.vue'
2020-05-07 15:10:53 +02:00
import { windowWidth, windowHeight } from './services/window_utils/window_utils'
2020-12-18 00:01:58 +01:00
import { mapGetters } from 'vuex'
2022-04-05 18:22:15 +02:00
import { defineAsyncComponent } from 'vue'
2016-10-26 19:03:55 +02:00
export default {
name: 'app',
components: {
2016-11-06 20:11:23 +01:00
UserPanel,
2016-11-27 19:44:56 +01:00
NavPanel,
2022-04-05 18:22:15 +02:00
Notifications: defineAsyncComponent(() => import('./components/notifications/notifications.vue')),
2018-02-11 15:12:05 +01:00
InstanceSpecificPanel,
2018-09-03 08:57:22 +02:00
FeaturesPanel,
2018-09-03 07:55:40 +02:00
WhoToFollowPanel,
ShoutPanel,
MediaModal,
SideDrawer,
2019-09-19 19:59:34 +02:00
MobilePostStatusButton,
2019-03-19 09:53:11 +01:00
MobileNav,
DesktopNav,
2022-06-13 00:36:41 +02:00
SettingsModal: defineAsyncComponent(() => import('./components/settings_modal/settings_modal.vue')),
2022-08-01 23:37:48 +02:00
UpdateNotification: defineAsyncComponent(() => import('./components/update_notification/update_notification.vue')),
UserReportingModal,
PostStatusModal,
2022-06-08 05:31:48 +02:00
EditStatusModal,
StatusHistoryModal,
GlobalNoticeList
2016-11-03 16:58:32 +01:00
},
2017-01-17 17:27:39 +01:00
data: () => ({
2020-11-01 15:44:57 +01:00
mobileActivePanel: 'timeline'
2017-01-17 17:27:39 +01:00
}),
created () {
// Load the locale from the storage
const val = this.$store.getters.mergedConfig.interfaceLanguage
this.$store.dispatch('setOption', { name: 'interfaceLanguage', value: val })
2019-03-03 15:33:40 +01:00
window.addEventListener('resize', this.updateMobileState)
},
unmounted () {
2019-03-03 15:33:40 +01:00
window.removeEventListener('resize', this.updateMobileState)
},
2016-11-03 16:58:32 +01:00
computed: {
classes () {
return [
{
'-reverse': this.reverseLayout,
'-no-sticky-headers': this.noSticky,
'-has-new-post-button': this.newPostButtonShown
},
'-' + this.layoutType
]
},
navClasses () {
const { navbarColumnStretch } = this.$store.getters.mergedConfig
return [
'-' + this.layoutType,
...(navbarColumnStretch ? ['-column-stretch'] : [])
]
},
2016-11-27 19:44:56 +01:00
currentUser () { return this.$store.state.users.currentUser },
2020-12-18 00:01:58 +01:00
userBackground () { return this.currentUser.background_image },
instanceBackground () {
return this.mergedConfig.hideInstanceWallpaper
? null
: this.$store.state.instance.background
2017-02-16 16:59:06 +01:00
},
2020-12-18 00:01:58 +01:00
background () { return this.userBackground || this.instanceBackground },
2019-02-03 21:32:24 +01:00
bgStyle () {
2020-12-18 00:01:58 +01:00
if (this.background) {
2020-12-16 17:25:07 +01:00
return {
'--body-background-image': `url(${this.background})`
}
2019-02-15 13:20:52 +01:00
}
},
2022-04-06 23:06:41 +02:00
shout () { return this.$store.state.shout.joined },
2018-09-09 20:21:23 +02:00
suggestionsEnabled () { return this.$store.state.instance.suggestionsEnabled },
2019-08-12 20:29:11 +02:00
showInstanceSpecificPanel () {
return this.$store.state.instance.showInstanceSpecificPanel &&
!this.$store.getters.mergedConfig.hideISP &&
2019-08-12 20:29:11 +02:00
this.$store.state.instance.instanceSpecificPanelContent
},
2022-04-11 22:30:41 +02:00
isChats () {
return this.$route.name === 'chat' || this.$route.name === 'chats'
},
2022-08-16 23:48:10 +02:00
isListEdit () {
return this.$route.name === 'lists-edit'
},
newPostButtonShown () {
2022-04-11 22:30:41 +02:00
if (this.isChats) return false
2022-08-16 23:48:10 +02:00
if (this.isListEdit) return false
return this.$store.getters.mergedConfig.alwaysShowNewPostButton || this.layoutType === 'mobile'
},
2019-03-03 15:33:40 +01:00
showFeaturesPanel () { return this.$store.state.instance.showFeaturesPanel },
editingAvailable () { return this.$store.state.instance.editingAvailable },
shoutboxPosition () {
2022-04-26 17:12:45 +02:00
return this.$store.getters.mergedConfig.alwaysShowNewPostButton || false
},
2021-06-14 22:33:51 +02:00
hideShoutbox () {
2021-06-14 21:42:56 +02:00
return this.$store.getters.mergedConfig.hideShoutbox
},
layoutType () { return this.$store.state.interface.layoutType },
privateMode () { return this.$store.state.instance.private },
reverseLayout () {
const { thirdColumnMode, sidebarRight: reverseSetting } = this.$store.getters.mergedConfig
if (this.layoutType !== 'wide') {
return reverseSetting
} else {
return thirdColumnMode === 'notifications' ? reverseSetting : !reverseSetting
}
},
noSticky () { return this.$store.getters.mergedConfig.disableStickyHeaders },
showScrollbars () { return this.$store.getters.mergedConfig.showScrollbars },
2020-12-18 00:01:58 +01:00
...mapGetters(['mergedConfig'])
2017-01-17 17:27:39 +01:00
},
methods: {
2019-03-03 15:33:40 +01:00
updateMobileState () {
this.$store.dispatch('setLayoutWidth', windowWidth())
this.$store.dispatch('setLayoutHeight', windowHeight())
2020-05-07 15:10:53 +02:00
}
2016-10-26 19:03:55 +02:00
}
}