diff options
| author | Henry Jameson <me@hjkos.com> | 2022-08-11 14:30:58 +0300 |
|---|---|---|
| committer | Henry Jameson <me@hjkos.com> | 2022-08-11 14:30:58 +0300 |
| commit | 6df99133548fb209bf365b77665931be477f0a30 (patch) | |
| tree | 5633b44a4080cc8f86ac39b2300fa88d7a5b6832 /src/components/timeline_menu/timeline_menu_content.js | |
| parent | 732733f115a863408a339e164ff88f1022c46101 (diff) | |
ability to pin items in navigation menu, initial draft version
Diffstat (limited to 'src/components/timeline_menu/timeline_menu_content.js')
| -rw-r--r-- | src/components/timeline_menu/timeline_menu_content.js | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/src/components/timeline_menu/timeline_menu_content.js b/src/components/timeline_menu/timeline_menu_content.js index 671570dd..c5b1cff2 100644 --- a/src/components/timeline_menu/timeline_menu_content.js +++ b/src/components/timeline_menu/timeline_menu_content.js @@ -17,12 +17,35 @@ library.add( ) const TimelineMenuContent = { + props: ['content'], + methods: { + isPinned (item) { + return this.pinnedItems.has(item) + }, + togglePin (item) { + if (this.isPinned(item)) { + this.$store.commit('removeCollectionPreference', { path: 'collections.pinnedNavItems', value: item }) + } else { + this.$store.commit('addCollectionPreference', { path: 'collections.pinnedNavItems', value: item }) + } + } + }, computed: { ...mapState({ currentUser: state => state.users.currentUser, privateMode: state => state.instance.private, - federating: state => state.instance.federating - }) + federating: state => state.instance.federating, + pinnedItems: state => new Set(state.serverSideStorage.prefsStorage.collections.pinnedNavItems) + }), + list () { + return (this.content || []).filter(({ criteria, anon, anonRoute }) => { + const set = new Set(criteria || []) + if (!this.federating && set.has('federating')) return false + if (this.private && set.has('!private')) return false + if (!this.currentUser && !(anon || anonRoute)) return false + return true + }) + } } } |
