pleroma-fe/src/components/navigation/navigation_entry.js
Henry Jameson 29e71c8a26 sss -> sc
2026-02-13 14:06:36 +02:00

57 lines
1.5 KiB
JavaScript

import { mapState as mapPiniaState, mapStores } from 'pinia'
import { mapState } from 'vuex'
import { routeTo } from 'src/components/navigation/navigation.js'
import OptionalRouterLink from 'src/components/optional_router_link/optional_router_link.vue'
import { useAnnouncementsStore } from 'src/stores/announcements.js'
import { useSyncConfigStore } from 'src/stores/sync_config.js'
import { library } from '@fortawesome/fontawesome-svg-core'
import { faThumbtack } from '@fortawesome/free-solid-svg-icons'
library.add(faThumbtack)
const NavigationEntry = {
props: ['item', 'showPin'],
components: {
OptionalRouterLink,
},
methods: {
isPinned(value) {
return this.pinnedItems.has(value)
},
togglePin(value) {
if (this.isPinned(value)) {
useSyncConfigStore().removeCollectionPreference({
path: 'collections.pinnedNavItems',
value,
})
} else {
useSyncConfigStore().addCollectionPreference({
path: 'collections.pinnedNavItems',
value,
})
}
useSyncConfigStore().pushSyncConfig()
},
},
computed: {
routeTo() {
return routeTo(this.item, this.currentUser)
},
getters() {
return this.$store.getters
},
...mapStores(useAnnouncementsStore),
...mapState({
currentUser: (state) => state.users.currentUser,
}),
...mapPiniaState(useSyncConfigStore, {
pinnedItems: (store) =>
new Set(store.prefsStorage.collections.pinnedNavItems),
}),
},
}
export default NavigationEntry