pleroma-fe/src/components/navigation/navigation_pins.js

125 lines
3.6 KiB
JavaScript
Raw Normal View History

import { library } from '@fortawesome/fontawesome-svg-core'
import {
2026-01-06 16:23:17 +02:00
faBell,
faBookmark,
2026-01-06 16:23:17 +02:00
faCity,
faComments,
2026-01-06 16:23:17 +02:00
faEnvelope,
faGlobe,
faInfoCircle,
2026-01-06 16:22:52 +02:00
faList,
2026-01-06 16:23:17 +02:00
faStream,
faUsers,
} from '@fortawesome/free-solid-svg-icons'
2026-01-06 16:23:17 +02:00
import { mapState as mapPiniaState } from 'pinia'
import {
filterNavigation,
getBookmarkFolderEntries,
getListEntries,
} from 'src/components/navigation/filter.js'
import {
ROOT_ITEMS,
routeTo,
TIMELINES,
} from 'src/components/navigation/navigation.js'
import StillImage from 'src/components/still-image/still-image.vue'
2025-01-30 21:56:07 +02:00
import { useAnnouncementsStore } from 'src/stores/announcements'
import { useBookmarkFoldersStore } from 'src/stores/bookmark_folders'
2026-01-06 16:23:17 +02:00
import { useListsStore } from 'src/stores/lists'
2025-03-23 20:03:25 +02:00
import { useServerSideStorageStore } from 'src/stores/serverSideStorage'
2026-01-06 16:23:17 +02:00
import { mapState } from 'vuex'
library.add(
faUsers,
faGlobe,
2025-06-24 15:56:08 +03:00
faCity,
faBookmark,
faEnvelope,
faComments,
faBell,
faInfoCircle,
faStream,
2026-01-06 16:22:52 +02:00
faList,
)
2022-08-23 15:36:54 +03:00
const NavPanel = {
props: ['limit'],
2022-08-23 15:36:54 +03:00
methods: {
2026-01-06 16:22:52 +02:00
getRouteTo(item) {
return routeTo(item, this.currentUser)
2026-01-06 16:22:52 +02:00
},
2022-08-23 15:36:54 +03:00
},
components: {
2026-01-06 16:22:52 +02:00
StillImage,
},
computed: {
2026-01-06 16:22:52 +02:00
getters() {
return this.$store.getters
},
2023-04-06 22:13:30 -06:00
...mapPiniaState(useListsStore, {
2026-01-06 16:22:52 +02:00
lists: getListEntries,
2023-04-06 22:13:30 -06:00
}),
2025-01-30 21:56:07 +02:00
...mapPiniaState(useAnnouncementsStore, {
2026-01-06 16:22:52 +02:00
supportsAnnouncements: (store) => store.supportsAnnouncements,
2025-01-30 21:56:07 +02:00
}),
...mapPiniaState(useBookmarkFoldersStore, {
2025-03-23 20:03:25 +02:00
bookmarks: getBookmarkFolderEntries,
}),
...mapPiniaState(useServerSideStorageStore, {
2026-01-06 16:22:52 +02:00
pinnedItems: (store) =>
new Set(store.prefsStorage.collections.pinnedNavItems),
}),
...mapState({
2026-01-06 16:22:52 +02:00
currentUser: (state) => state.users.currentUser,
followRequestCount: (state) => state.api.followRequests.length,
privateMode: (state) => state.instance.private,
federating: (state) => state.instance.federating,
pleromaChatMessagesAvailable: (state) =>
state.instance.pleromaChatMessagesAvailable,
bubbleTimeline: (state) => state.instance.localBubbleInstances.length > 0,
}),
2026-01-06 16:22:52 +02:00
pinnedList() {
2022-08-12 00:50:08 +03:00
if (!this.currentUser) {
2026-01-06 16:22:52 +02:00
return filterNavigation(
[
{ ...TIMELINES.public, name: 'public' },
{ ...TIMELINES.twkn, name: 'twkn' },
{ ...ROOT_ITEMS.about, name: 'about' },
],
{
hasChats: this.pleromaChatMessagesAvailable,
hasAnnouncements: this.supportsAnnouncements,
isFederating: this.federating,
isPrivate: this.privateMode,
currentUser: this.currentUser,
supportsBubbleTimeline: this.bubbleTimeline,
supportsBookmarkFolders: this.bookmarks,
},
)
2022-08-12 00:50:08 +03:00
}
return filterNavigation(
[
2026-01-06 16:22:52 +02:00
...Object.entries({ ...TIMELINES })
.filter(([k]) => this.pinnedItems.has(k))
.map(([k, v]) => ({ ...v, name: k })),
...this.lists.filter((k) => this.pinnedItems.has(k.name)),
...this.bookmarks.filter((k) => this.pinnedItems.has(k.name)),
2026-01-06 16:22:52 +02:00
...Object.entries({ ...ROOT_ITEMS })
.filter(([k]) => this.pinnedItems.has(k))
2026-01-06 16:22:52 +02:00
.map(([k, v]) => ({ ...v, name: k })),
],
{
hasChats: this.pleromaChatMessagesAvailable,
hasAnnouncements: this.supportsAnnouncements,
2025-06-24 15:56:08 +03:00
supportsBubbleTimeline: this.bubbleTimeline,
2025-06-24 17:01:17 +03:00
supportsBookmarkFolders: this.bookmarks,
isFederating: this.federating,
2022-08-12 01:19:19 +03:00
isPrivate: this.privateMode,
2026-01-06 16:22:52 +02:00
currentUser: this.currentUser,
},
).slice(0, this.limit)
2026-01-06 16:22:52 +02:00
},
},
}
export default NavPanel