aboutsummaryrefslogtreecommitdiff
path: root/src/components/mobile_nav/mobile_nav.js
blob: fd373ac12e7e32e7d15652aa02337ab06246859a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import SideDrawer from '../side_drawer/side_drawer.vue'
import Notifications from '../notifications/notifications.vue'
import MobilePostStatusModal from '../mobile_post_status_modal/mobile_post_status_modal.vue'
import { unseenNotificationsFromStore } from '../../services/notification_utils/notification_utils'

const MobileNav = {
  components: {
    SideDrawer,
    Notifications,
    MobilePostStatusModal
  },
  data: () => ({
    notificationsOpen: false
  }),
  computed: {
    currentUser () {
      return this.$store.state.users.currentUser
    },
    unseenNotifications () {
      return unseenNotificationsFromStore(this.$store)
    },
    unseenNotificationsCount () {
      return this.unseenNotifications.length
    },
    sitename () { return this.$store.state.instance.name }
  },
  methods: {
    toggleMobileSidebar () {
      this.$refs.sideDrawer.toggleDrawer()
    },
    toggleMobileNotifications () {
      this.notificationsOpen = !this.notificationsOpen
      if (!this.notificationsOpen) {
        this.markNotificationsAsSeen()
      }
    },
    scrollToTop () {
      window.scrollTo(0, 0)
    },
    logout () {
      this.$router.replace('/main/public')
      this.$store.dispatch('logout')
    },
    markNotificationsAsSeen () {
      this.$refs.notifications.markAsSeen()
    }
  }
}

export default MobileNav