akkoma-fe/src/components/side_drawer/side_drawer.js

114 lines
2.7 KiB
JavaScript
Raw Normal View History

2020-05-07 13:10:53 +00:00
import { mapState, mapGetters } from 'vuex'
2019-03-05 19:01:49 +00:00
import UserCard from '../user_card/user_card.vue'
import { unseenNotificationsFromStore } from '../../services/notification_utils/notification_utils'
2019-03-25 20:44:58 +00:00
import GestureService from '../../services/gesture_service/gesture_service'
import { library } from '@fortawesome/fontawesome-svg-core'
import {
faSignInAlt,
faSignOutAlt,
faHome,
faComments,
faBell,
faUserPlus,
faBullhorn,
faSearch,
faTachometerAlt,
faCog,
2022-06-14 20:53:51 +00:00
faInfoCircle,
faList
} from '@fortawesome/free-solid-svg-icons'
library.add(
faSignInAlt,
faSignOutAlt,
faHome,
faComments,
faBell,
faUserPlus,
faBullhorn,
faSearch,
faTachometerAlt,
faCog,
2022-06-14 20:53:51 +00:00
faInfoCircle,
faList
)
const SideDrawer = {
props: [ 'logout' ],
data: () => ({
closed: true,
2019-03-25 20:44:58 +00:00
closeGesture: undefined
}),
2019-03-25 20:44:58 +00:00
created () {
this.closeGesture = GestureService.swipeGesture(GestureService.DIRECTION_LEFT, this.toggleDrawer)
if (this.currentUser && this.currentUser.locked) {
2020-01-21 15:51:49 +00:00
this.$store.dispatch('startFetchingFollowRequests')
}
2019-03-25 20:44:58 +00:00
},
2019-03-05 19:01:49 +00:00
components: { UserCard },
computed: {
currentUser () {
return this.$store.state.users.currentUser
},
2022-04-06 21:06:41 +00:00
shout () { return this.$store.state.shout.joined },
unseenNotifications () {
return unseenNotificationsFromStore(this.$store)
},
unseenNotificationsCount () {
return this.unseenNotifications.length
2019-01-16 02:33:08 +00:00
},
suggestionsEnabled () {
return this.$store.state.instance.suggestionsEnabled
},
logo () {
return this.$store.state.instance.logo
},
hideSitename () {
return this.$store.state.instance.hideSitename
},
sitename () {
return this.$store.state.instance.name
},
followRequestCount () {
return this.$store.state.api.followRequests.length
2019-11-11 20:37:14 +00:00
},
privateMode () {
return this.$store.state.instance.private
},
federating () {
return this.$store.state.instance.federating
},
timelinesRoute () {
if (this.$store.state.interface.lastTimeline) {
return this.$store.state.interface.lastTimeline
}
return this.currentUser ? 'friends' : 'public-timeline'
2020-07-14 08:44:06 +00:00
},
2020-05-07 13:10:53 +00:00
...mapState({
pleromaChatMessagesAvailable: state => state.instance.pleromaChatMessagesAvailable
}),
...mapGetters(['unreadChatCount', 'unreadAnnouncementCount'])
2018-12-20 20:20:04 +00:00
},
methods: {
toggleDrawer () {
this.closed = !this.closed
},
2018-12-22 15:32:07 +00:00
doLogout () {
this.logout()
this.toggleDrawer()
},
touchStart (e) {
2019-03-25 20:44:58 +00:00
GestureService.beginSwipe(e, this.closeGesture)
},
touchMove (e) {
2019-03-25 20:44:58 +00:00
GestureService.updateSwipe(e, this.closeGesture)
},
openSettingsModal () {
this.$store.dispatch('openSettingsModal')
2020-05-25 13:56:32 +00:00
}
}
}
export default SideDrawer