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

54 lines
1.6 KiB
JavaScript
Raw Normal View History

import { library } from '@fortawesome/fontawesome-svg-core'
import { faThumbtack } from '@fortawesome/free-solid-svg-icons'
2026-01-06 16:23:17 +02:00
import { mapState as mapPiniaState, mapStores } from 'pinia'
import { routeTo } from 'src/components/navigation/navigation.js'
import OptionalRouterLink from 'src/components/optional_router_link/optional_router_link.vue'
2025-02-03 13:02:14 +02:00
import { useAnnouncementsStore } from 'src/stores/announcements'
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(faThumbtack)
const NavigationEntry = {
props: ['item', 'showPin'],
components: {
2026-01-06 16:22:52 +02:00
OptionalRouterLink,
},
methods: {
2026-01-06 16:22:52 +02:00
isPinned(value) {
return this.pinnedItems.has(value)
},
2026-01-06 16:22:52 +02:00
togglePin(value) {
if (this.isPinned(value)) {
2026-01-06 16:22:52 +02:00
useServerSideStorageStore().removeCollectionPreference({
path: 'collections.pinnedNavItems',
value,
})
} else {
2026-01-06 16:22:52 +02:00
useServerSideStorageStore().addCollectionPreference({
path: 'collections.pinnedNavItems',
value,
})
}
2025-03-23 20:03:25 +02:00
useServerSideStorageStore().pushServerSideStorage()
2026-01-06 16:22:52 +02:00
},
},
computed: {
2026-01-06 16:22:52 +02:00
routeTo() {
return routeTo(this.item, this.currentUser)
2022-08-23 15:36:54 +03:00
},
2026-01-06 16:22:52 +02:00
getters() {
return this.$store.getters
},
2023-04-06 16:32:21 -06:00
...mapStores(useAnnouncementsStore),
...mapState({
2026-01-06 16:22:52 +02:00
currentUser: (state) => state.users.currentUser,
2025-03-23 20:03:25 +02:00
}),
...mapPiniaState(useServerSideStorageStore, {
2026-01-06 16:22:52 +02:00
pinnedItems: (store) =>
new Set(store.prefsStorage.collections.pinnedNavItems),
2025-03-23 20:03:25 +02:00
}),
2026-01-06 16:22:52 +02:00
},
}
export default NavigationEntry