diff options
| author | tusooa <tusooa@kazv.moe> | 2022-08-30 00:14:30 +0000 |
|---|---|---|
| committer | tusooa <tusooa@kazv.moe> | 2022-08-30 00:14:30 +0000 |
| commit | 8b25febe36a97d113c846928dab22ab36158ee07 (patch) | |
| tree | f6f63b05e4bbc9d17258a4a559a2dc1970bbf047 /src/components/navigation/navigation_entry.js | |
| parent | 3b6c31f3b3d2326ffbe258c826f6dbd3f5374cf2 (diff) | |
| parent | dbb6f224425e059e2edc6018d0b009cc87a0aea4 (diff) | |
Merge branch 'navigation-update' into 'develop'
Navigation update + preferences storage (and some minor fixes)
See merge request pleroma/pleroma-fe!1592
Diffstat (limited to 'src/components/navigation/navigation_entry.js')
| -rw-r--r-- | src/components/navigation/navigation_entry.js | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/components/navigation/navigation_entry.js b/src/components/navigation/navigation_entry.js new file mode 100644 index 00000000..fe3402fc --- /dev/null +++ b/src/components/navigation/navigation_entry.js @@ -0,0 +1,47 @@ +import { mapState } from 'vuex' +import { USERNAME_ROUTES } from 'src/components/navigation/navigation.js' +import { library } from '@fortawesome/fontawesome-svg-core' +import { faThumbtack } from '@fortawesome/free-solid-svg-icons' + +library.add(faThumbtack) + +const NavigationEntry = { + props: ['item', 'showPin'], + methods: { + isPinned (value) { + return this.pinnedItems.has(value) + }, + togglePin (value) { + if (this.isPinned(value)) { + this.$store.commit('removeCollectionPreference', { path: 'collections.pinnedNavItems', value }) + } else { + this.$store.commit('addCollectionPreference', { path: 'collections.pinnedNavItems', value }) + } + this.$store.dispatch('pushServerSideStorage') + } + }, + computed: { + routeTo () { + if (!this.item.route && !this.item.routeObject) return null + let route + if (this.item.routeObject) { + route = this.item.routeObject + } else { + route = { name: (this.item.anon || this.currentUser) ? this.item.route : this.item.anonRoute } + } + if (USERNAME_ROUTES.has(route.name)) { + route.params = { username: this.currentUser.screen_name, name: this.currentUser.screen_name } + } + return route + }, + getters () { + return this.$store.getters + }, + ...mapState({ + currentUser: state => state.users.currentUser, + pinnedItems: state => new Set(state.serverSideStorage.prefsStorage.collections.pinnedNavItems) + }) + } +} + +export default NavigationEntry |
