2018-12-24 04:50:19 +11:00
|
|
|
import UserCardContent from '../user_card_content/user_card_content.vue'
|
2018-12-29 06:39:54 +11:00
|
|
|
import { unseenNotificationsFromStore } from '../../services/notification_utils/notification_utils'
|
2018-12-24 04:50:19 +11:00
|
|
|
|
2018-12-29 06:39:54 +11:00
|
|
|
const deltaCoord = (oldCoord, newCoord) => [newCoord[0] - oldCoord[0], newCoord[1] - oldCoord[1]]
|
2018-12-24 04:50:19 +11:00
|
|
|
|
2018-12-29 06:39:54 +11:00
|
|
|
const touchEventCoord = e => ([e.touches[0].screenX, e.touches[0].screenY])
|
2018-12-24 04:50:19 +11:00
|
|
|
|
2018-12-16 04:13:01 +11:00
|
|
|
const SideDrawer = {
|
2018-12-29 06:39:54 +11:00
|
|
|
props: [ 'logout' ],
|
2018-12-24 04:50:19 +11:00
|
|
|
data: () => ({
|
|
|
|
closed: true,
|
2018-12-29 06:39:54 +11:00
|
|
|
touchCoord: [0, 0]
|
2018-12-24 04:50:19 +11:00
|
|
|
}),
|
|
|
|
components: { UserCardContent },
|
2018-12-16 04:13:01 +11:00
|
|
|
computed: {
|
|
|
|
currentUser () {
|
|
|
|
return this.$store.state.users.currentUser
|
2018-12-29 06:39:54 +11:00
|
|
|
},
|
|
|
|
chat () { return this.$store.state.chat.channel.state === 'joined' },
|
|
|
|
unseenNotifications () {
|
|
|
|
return unseenNotificationsFromStore(this.$store)
|
|
|
|
},
|
|
|
|
unseenNotificationsCount () {
|
|
|
|
return this.unseenNotifications.length
|
2018-12-21 07:20:04 +11:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
2018-12-24 04:50:19 +11:00
|
|
|
toggleDrawer () {
|
|
|
|
this.closed = !this.closed
|
|
|
|
},
|
2018-12-23 02:32:07 +11:00
|
|
|
doLogout () {
|
|
|
|
this.logout()
|
2018-12-29 06:39:54 +11:00
|
|
|
this.toggleDrawer()
|
2018-12-24 04:50:19 +11:00
|
|
|
},
|
|
|
|
touchStart (e) {
|
2018-12-29 06:39:54 +11:00
|
|
|
this.touchCoord = touchEventCoord(e)
|
2018-12-24 04:50:19 +11:00
|
|
|
},
|
|
|
|
touchMove (e) {
|
2018-12-29 06:39:54 +11:00
|
|
|
const delta = deltaCoord(this.touchCoord, touchEventCoord(e))
|
|
|
|
if (delta[0] < -30 && Math.abs(delta[1]) < Math.abs(delta[0]) && !this.closed) {
|
2018-12-24 04:50:19 +11:00
|
|
|
this.toggleDrawer()
|
|
|
|
}
|
2018-12-16 04:13:01 +11:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default SideDrawer
|