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

132 lines
3.4 KiB
JavaScript
Raw Normal View History

2026-01-29 15:11:47 +02:00
import { mapActions, mapState } from 'pinia'
2026-01-29 15:07:00 +02:00
import { mapGetters } from 'vuex'
2026-01-08 17:26:52 +02:00
import { USERNAME_ROUTES } from 'src/components/navigation/navigation.js'
import { useAnnouncementsStore } from 'src/stores/announcements'
import { useInstanceStore } from 'src/stores/instance.js'
2026-01-08 17:26:52 +02:00
import { useInterfaceStore } from 'src/stores/interface'
import { useShoutStore } from 'src/stores/shout'
import GestureService from '../../services/gesture_service/gesture_service'
import { unseenNotificationsFromStore } from '../../services/notification_utils/notification_utils'
import UserCard from '../user_card/user_card.vue'
import { library } from '@fortawesome/fontawesome-svg-core'
import {
faBell,
faBullhorn,
faCog,
2026-01-06 16:23:17 +02:00
faComments,
faCompass,
2026-01-06 16:22:52 +02:00
faFilePen,
2026-01-06 16:23:17 +02:00
faHome,
faInfoCircle,
faList,
faSearch,
faSignInAlt,
faSignOutAlt,
faTachometerAlt,
faUserPlus,
} from '@fortawesome/free-solid-svg-icons'
library.add(
faSignInAlt,
faSignOutAlt,
faHome,
faComments,
faBell,
faUserPlus,
faBullhorn,
faSearch,
faTachometerAlt,
faCog,
2022-08-06 17:26:43 +03:00
faInfoCircle,
faCompass,
2023-03-10 20:26:13 -05:00
faList,
2026-01-06 16:22:52 +02:00
faFilePen,
)
const SideDrawer = {
2022-07-31 12:35:48 +03:00
props: ['logout'],
data: () => ({
closed: true,
2026-01-06 16:22:52 +02:00
closeGesture: undefined,
}),
2026-01-06 16:22:52 +02:00
created() {
this.closeGesture = GestureService.swipeGesture(
GestureService.DIRECTION_LEFT,
this.toggleDrawer,
)
if (this.currentUser && this.currentUser.locked) {
2020-01-21 16:51:49 +01:00
this.$store.dispatch('startFetchingFollowRequests')
}
2019-03-25 22:44:58 +02:00
},
2019-03-05 14:01:49 -05:00
components: { UserCard },
computed: {
2026-01-06 16:22:52 +02:00
currentUser() {
return this.$store.state.users.currentUser
},
2026-01-06 16:22:52 +02:00
shout() {
return useShoutStore().joined
},
unseenNotifications() {
return unseenNotificationsFromStore(this.$store)
},
2026-01-06 16:22:52 +02:00
unseenNotificationsCount() {
return this.unseenNotifications.length
2019-01-16 02:33:08 +00:00
},
2026-01-06 16:22:52 +02:00
followRequestCount() {
return this.$store.state.api.followRequests.length
2019-11-11 14:37:14 -06:00
},
2026-01-06 16:22:52 +02:00
privateMode() {
return useInstanceStore().private
2019-11-11 14:37:14 -06:00
},
2026-01-06 16:22:52 +02:00
federating() {
return useInstanceStore().federating
},
2026-01-06 16:22:52 +02:00
timelinesRoute() {
2022-08-23 22:10:21 +03:00
let name
2023-04-05 21:06:37 -06:00
if (useInterfaceStore().lastTimeline) {
name = useInterfaceStore().lastTimeline
2022-08-23 22:10:21 +03:00
}
name = this.currentUser ? 'friends' : 'public-timeline'
if (USERNAME_ROUTES.has(name)) {
2022-08-23 22:18:33 +03:00
return { name, params: { username: this.currentUser.screen_name } }
2022-08-23 22:10:21 +03:00
} else {
return { name }
}
2020-07-14 11:44:06 +03:00
},
2026-01-29 15:07:00 +02:00
...mapState(useAnnouncementsStore, [
'supportsAnnouncements',
'unreadAnnouncementCount',
]),
...mapState(useInstanceStore, ['private', 'federating']),
...mapState(useInstanceStore, {
logo: (store) => store.instanceIdentity.logo,
sitename: (store) => store.instanceIdentity.name,
hideSitename: (store) => store.instanceIdentity.hideSitename,
2026-01-29 15:11:47 +02:00
pleromaChatMessagesAvailable: (store) =>
store.featureSet.pleromaChatMessagesAvailable,
2026-01-29 15:07:00 +02:00
suggestionsEnabled: (store) => store.featureSet.suggestionsEnabled,
2020-05-07 16:10:53 +03:00
}),
2026-01-06 16:22:52 +02:00
...mapGetters(['unreadChatCount', 'draftCount']),
2018-12-20 22:20:04 +02:00
},
methods: {
2026-01-06 16:22:52 +02:00
toggleDrawer() {
this.closed = !this.closed
},
2026-01-06 16:22:52 +02:00
doLogout() {
2018-12-22 17:32:07 +02:00
this.logout()
this.toggleDrawer()
},
2026-01-06 16:22:52 +02:00
touchStart(e) {
2019-03-25 22:44:58 +02:00
GestureService.beginSwipe(e, this.closeGesture)
},
2026-01-06 16:22:52 +02:00
touchMove(e) {
2019-03-25 22:44:58 +02:00
GestureService.updateSwipe(e, this.closeGesture)
},
2026-01-29 15:11:47 +02:00
...mapActions(useInterfaceStore, ['openSettingsModal']),
2026-01-06 16:22:52 +02:00
},
}
export default SideDrawer