Skip to content
Snippets Groups Projects
App.js 4.59 KiB
Newer Older
  • Learn to ignore specific revisions
  • lain's avatar
    lain committed
    import UserPanel from './components/user_panel/user_panel.vue'
    
    lain's avatar
    lain committed
    import NavPanel from './components/nav_panel/nav_panel.vue'
    
    import InstanceSpecificPanel from './components/instance_specific_panel/instance_specific_panel.vue'
    
    hakabahitoyo's avatar
    hakabahitoyo committed
    import FeaturesPanel from './components/features_panel/features_panel.vue'
    
    Hakaba Hitoyo's avatar
    Hakaba Hitoyo committed
    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'
    
    Tae Hoon's avatar
    Tae Hoon committed
    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'
    
    Tae Hoon's avatar
    Tae Hoon committed
    import UserReportingModal from './components/user_reporting_modal/user_reporting_modal.vue'
    
    import PostStatusModal from './components/post_status_modal/post_status_modal.vue'
    
    import GlobalNoticeList from './components/global_notice_list/global_notice_list.vue'
    
    Eugenij's avatar
    Eugenij committed
    import { windowWidth, windowHeight } from './services/window_utils/window_utils'
    
    HJ's avatar
    HJ committed
    import { mapGetters } from 'vuex'
    
    HJ's avatar
    HJ committed
    import { defineAsyncComponent } from 'vue'
    
    lain's avatar
    .
    lain committed
    
    export default {
      name: 'app',
      components: {
    
    lain's avatar
    lain committed
        UserPanel,
    
    lain's avatar
    lain committed
        NavPanel,
    
    HJ's avatar
    HJ committed
        Notifications: defineAsyncComponent(() => import('./components/notifications/notifications.vue')),
    
    Hakaba Hitoyo's avatar
    Hakaba Hitoyo committed
        InstanceSpecificPanel,
    
    hakabahitoyo's avatar
    hakabahitoyo committed
        FeaturesPanel,
    
    hakabahitoyo's avatar
    hakabahitoyo committed
        WhoToFollowPanel,
    
    Tae Hoon's avatar
    Tae Hoon committed
        MobilePostStatusButton,
    
    Tae Hoon's avatar
    Tae Hoon committed
        MobileNav,
    
    HJ's avatar
    HJ committed
        SettingsModal: defineAsyncComponent(() => import('./components/settings_modal/settings_modal.vue')),
    
        UserReportingModal,
    
        PostStatusModal,
        GlobalNoticeList
    
    lain's avatar
    lain committed
      },
    
    lain's avatar
    lain committed
      data: () => ({
    
    HJ's avatar
    HJ committed
        mobileActivePanel: 'timeline'
    
    lain's avatar
    lain committed
      }),
    
      created () {
        // Load the locale from the storage
    
        const val = this.$store.getters.mergedConfig.interfaceLanguage
        this.$store.dispatch('setOption', { name: 'interfaceLanguage', value: val })
    
        window.addEventListener('resize', this.updateMobileState)
      },
    
      unmounted () {
    
        window.removeEventListener('resize', this.updateMobileState)
    
    lain's avatar
    lain committed
      computed: {
    
        classes () {
          return [
            {
              '-reverse': this.reverseLayout,
              '-no-sticky-headers': this.noSticky,
              '-has-new-post-button': this.newPostButtonShown
            },
            '-' + this.layoutType
          ]
        },
    
    lain's avatar
    lain committed
        currentUser () { return this.$store.state.users.currentUser },
    
    HJ's avatar
    HJ committed
        userBackground () { return this.currentUser.background_image },
        instanceBackground () {
          return this.mergedConfig.hideInstanceWallpaper
            ? null
            : this.$store.state.instance.background
    
    lain's avatar
    lain committed
        },
    
    HJ's avatar
    HJ committed
        background () { return this.userBackground || this.instanceBackground },
    
    Tae Hoon's avatar
    Tae Hoon committed
        bgStyle () {
    
    HJ's avatar
    HJ committed
          if (this.background) {
    
    HJ's avatar
    HJ committed
            return {
              '--body-background-image': `url(${this.background})`
            }
    
        shout () { return this.$store.state.shout.joined },
    
    HJ's avatar
    HJ committed
        suggestionsEnabled () { return this.$store.state.instance.suggestionsEnabled },
    
        showInstanceSpecificPanel () {
          return this.$store.state.instance.showInstanceSpecificPanel &&
    
            !this.$store.getters.mergedConfig.hideISP &&
    
            this.$store.state.instance.instanceSpecificPanelContent
        },
    
    HJ's avatar
    HJ committed
        isChats () {
          return this.$route.name === 'chat' || this.$route.name === 'chats'
        },
    
        newPostButtonShown () {
    
    HJ's avatar
    HJ committed
          if (this.isChats) return false
    
          return this.$store.getters.mergedConfig.alwaysShowNewPostButton || this.layoutType === 'mobile'
        },
    
        showFeaturesPanel () { return this.$store.state.instance.showFeaturesPanel },
    
        shoutboxPosition () {
    
    HJ's avatar
    HJ committed
          return this.$store.getters.mergedConfig.alwaysShowNewPostButton || false
    
    eris's avatar
    eris committed
        hideShoutbox () {
    
    eris's avatar
    eris committed
          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 },
    
    HJ's avatar
    HJ committed
        ...mapGetters(['mergedConfig'])
    
    lain's avatar
    lain committed
      },
      methods: {
    
        updateMobileState () {
    
          this.$store.dispatch('setLayoutWidth', windowWidth())
          this.$store.dispatch('setLayoutHeight', windowHeight())
    
    Eugenij's avatar
    Eugenij committed
        }
    
    lain's avatar
    .
    lain committed
      }
    }