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

57 lines
1.5 KiB
JavaScript
Raw Normal View History

2026-01-06 16:23:17 +02:00
import { mapState as mapPiniaState, mapStores } from 'pinia'
2026-01-08 17:26:52 +02:00
import { mapState } from 'vuex'
2026-01-06 16:23:17 +02:00
import { routeTo } from 'src/components/navigation/navigation.js'
import OptionalRouterLink from 'src/components/optional_router_link/optional_router_link.vue'
2026-01-29 20:40:00 +02:00
2026-01-29 20:44:55 +02:00
import { useAnnouncementsStore } from 'src/stores/announcements.js'
2026-02-13 13:59:00 +02:00
import { useSyncConfigStore } from 'src/stores/sync_config.js'
2026-01-08 17:26:52 +02:00
import { library } from '@fortawesome/fontawesome-svg-core'
import { faThumbtack } from '@fortawesome/free-solid-svg-icons'
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-02-13 13:59:00 +02:00
useSyncConfigStore().removeCollectionPreference({
2026-01-06 16:22:52 +02:00
path: 'collections.pinnedNavItems',
value,
})
} else {
2026-02-13 13:59:00 +02:00
useSyncConfigStore().addCollectionPreference({
2026-01-06 16:22:52 +02:00
path: 'collections.pinnedNavItems',
value,
})
}
2026-02-13 13:59:00 +02:00
useSyncConfigStore().pushSyncConfig()
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
}),
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),
2025-03-23 20:03:25 +02:00
}),
2026-01-06 16:22:52 +02:00
},
}
export default NavigationEntry