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

128 lines
3.6 KiB
JavaScript
Raw Normal View History

2026-01-06 16:23:17 +02:00
import { mapState as mapPiniaState } from 'pinia'
2026-01-08 17:26:52 +02:00
import { mapState } from 'vuex'
2026-01-06 16:23:17 +02:00
import {
filterNavigation,
getBookmarkFolderEntries,
getListEntries,
} from 'src/components/navigation/filter.js'
import {
ROOT_ITEMS,
routeTo,
TIMELINES,
} from 'src/components/navigation/navigation.js'
2025-01-30 21:56:07 +02:00
import { useAnnouncementsStore } from 'src/stores/announcements'
import { useBookmarkFoldersStore } from 'src/stores/bookmark_folders'
import { useInstanceStore } from 'src/stores/instance.js'
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
2026-01-06 16:23:17 +02:00
import { useListsStore } from 'src/stores/lists'
2026-02-13 13:59:00 +02:00
import { useSyncConfigStore } from 'src/stores/sync_config.js'
2026-08-10 15:00:59 +03:00
import { useUsersStore } from 'src/stores/users.js'
2026-01-08 17:26:52 +02:00
import { library } from '@fortawesome/fontawesome-svg-core'
import {
faBell,
faBookmark,
faCity,
faComments,
faEnvelope,
faGlobe,
faInfoCircle,
faList,
faStream,
faUsers,
} from '@fortawesome/free-solid-svg-icons'
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
},
2026-06-04 21:59:09 +03:00
components: {},
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,
}),
2026-02-13 13:59:00 +02:00
...mapPiniaState(useSyncConfigStore, {
2026-01-06 16:22:52 +02:00
pinnedItems: (store) =>
new Set(store.prefsStorage.collections.pinnedNavItems),
}),
2026-02-05 01:28:56 +02:00
...mapPiniaState(useInstanceStore, ['privateMode', 'federating']),
...mapPiniaState(useInstanceCapabilitiesStore, [
'pleromaChatMessagesAvailable',
'localBubble',
]),
2026-08-10 15:00:59 +03:00
...mapPiniaState(useUsersStore, ['currentUser']),
...mapState({
2026-01-06 16:22:52 +02:00
followRequestCount: (state) => state.api.followRequests.length,
}),
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,
2026-02-05 01:28:56 +02:00
isPrivate: this.privateMode,
2026-01-06 16:22:52 +02:00
currentUser: this.currentUser,
supportsBubbleTimeline: this.localBubble,
2026-01-06 16:22:52 +02:00
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,
supportsBubbleTimeline: this.localBubble,
2025-06-24 17:01:17 +03:00
supportsBookmarkFolders: this.bookmarks,
isFederating: this.federating,
2026-02-05 01:28:56 +02: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