2019-03-12 14:50:54 -07:00
|
|
|
import SideDrawer from '../side_drawer/side_drawer.vue'
|
|
|
|
import Notifications from '../notifications/notifications.vue'
|
2019-03-14 08:46:04 -07:00
|
|
|
import MobilePostStatusModal from '../mobile_post_status_modal/mobile_post_status_modal.vue'
|
2019-03-12 14:50:54 -07:00
|
|
|
import { unseenNotificationsFromStore } from '../../services/notification_utils/notification_utils'
|
|
|
|
|
|
|
|
const MobileNav = {
|
|
|
|
components: {
|
|
|
|
SideDrawer,
|
2019-03-14 08:46:04 -07:00
|
|
|
Notifications,
|
|
|
|
MobilePostStatusModal
|
2019-03-12 14:50:54 -07:00
|
|
|
},
|
|
|
|
data: () => ({
|
|
|
|
notificationsOpen: false
|
|
|
|
}),
|
|
|
|
computed: {
|
2019-03-14 11:40:56 -07:00
|
|
|
currentUser () {
|
|
|
|
return this.$store.state.users.currentUser
|
|
|
|
},
|
2019-03-12 14:50:54 -07:00
|
|
|
unseenNotifications () {
|
|
|
|
return unseenNotificationsFromStore(this.$store)
|
|
|
|
},
|
|
|
|
unseenNotificationsCount () {
|
|
|
|
return this.unseenNotifications.length
|
|
|
|
},
|
|
|
|
sitename () { return this.$store.state.instance.name }
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
toggleMobileSidebar () {
|
|
|
|
this.$refs.sideDrawer.toggleDrawer()
|
|
|
|
},
|
2019-03-23 13:03:38 -07:00
|
|
|
openMobileNotifications () {
|
|
|
|
this.notificationsOpen = true
|
|
|
|
},
|
|
|
|
closeMobileNotifications () {
|
|
|
|
if (this.notificationsOpen) {
|
|
|
|
// make sure to mark notifs seen only when the notifs were open and not
|
|
|
|
// from close-calls.
|
|
|
|
this.notificationsOpen = false
|
2019-03-14 08:46:04 -07:00
|
|
|
this.markNotificationsAsSeen()
|
|
|
|
}
|
2019-03-12 14:50:54 -07:00
|
|
|
},
|
|
|
|
scrollToTop () {
|
|
|
|
window.scrollTo(0, 0)
|
2019-03-14 08:46:04 -07:00
|
|
|
},
|
|
|
|
logout () {
|
|
|
|
this.$router.replace('/main/public')
|
|
|
|
this.$store.dispatch('logout')
|
|
|
|
},
|
|
|
|
markNotificationsAsSeen () {
|
|
|
|
this.$refs.notifications.markAsSeen()
|
2019-03-12 14:50:54 -07:00
|
|
|
}
|
2019-03-23 13:03:38 -07:00
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
$route () {
|
|
|
|
// handles closing notificaitons when you press any router-link on the
|
|
|
|
// notifications.
|
|
|
|
this.closeMobileNotifications()
|
|
|
|
}
|
2019-03-12 14:50:54 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default MobileNav
|