fix private mode & timelines dropdown

This commit is contained in:
Henry Jameson 2022-12-15 00:53:32 +02:00
parent bcb24938aa
commit d6c8821d37
3 changed files with 28 additions and 5 deletions

View File

@ -2,7 +2,7 @@ export const filterNavigation = (list = [], { hasChats, hasAnnouncements, isFede
return list.filter(({ criteria, anon, anonRoute }) => { return list.filter(({ criteria, anon, anonRoute }) => {
const set = new Set(criteria || []) const set = new Set(criteria || [])
if (!isFederating && set.has('federating')) return false if (!isFederating && set.has('federating')) return false
if (isPrivate && set.has('!private')) return false if (!currentUser && isPrivate && set.has('!private')) return false
if (!currentUser && !(anon || anonRoute)) return false if (!currentUser && !(anon || anonRoute)) return false
if ((!currentUser || !currentUser.locked) && set.has('lockedUser')) return false if ((!currentUser || !currentUser.locked) && set.has('lockedUser')) return false
if (!hasChats && set.has('chats')) return false if (!hasChats && set.has('chats')) return false

View File

@ -56,11 +56,17 @@ const NavPanel = {
}), }),
pinnedList () { pinnedList () {
if (!this.currentUser) { if (!this.currentUser) {
return [ return filterNavigation([
{ ...TIMELINES.public, name: 'public' }, { ...TIMELINES.public, name: 'public' },
{ ...TIMELINES.twkn, name: 'twkn' }, { ...TIMELINES.twkn, name: 'twkn' },
{ ...ROOT_ITEMS.about, name: 'about' } { ...ROOT_ITEMS.about, name: 'about' }
] ],
{
hasChats: this.pleromaChatMessagesAvailable,
isFederating: this.federating,
isPrivate: this.privateMode,
currentUser: this.currentUser
})
} }
return filterNavigation( return filterNavigation(
[ [

View File

@ -1,8 +1,10 @@
import Popover from '../popover/popover.vue' import Popover from '../popover/popover.vue'
import NavigationEntry from 'src/components/navigation/navigation_entry.vue' import NavigationEntry from 'src/components/navigation/navigation_entry.vue'
import { mapState } from 'vuex'
import { ListsMenuContent } from '../lists_menu/lists_menu_content.vue' import { ListsMenuContent } from '../lists_menu/lists_menu_content.vue'
import { library } from '@fortawesome/fontawesome-svg-core' import { library } from '@fortawesome/fontawesome-svg-core'
import { TIMELINES } from 'src/components/navigation/navigation.js' import { TIMELINES } from 'src/components/navigation/navigation.js'
import { filterNavigation } from 'src/components/navigation/filter.js'
import { import {
faChevronDown faChevronDown
} from '@fortawesome/free-solid-svg-icons' } from '@fortawesome/free-solid-svg-icons'
@ -29,8 +31,7 @@ const TimelineMenu = {
}, },
data () { data () {
return { return {
isOpen: false, isOpen: false
timelinesList: Object.entries(TIMELINES).map(([k, v]) => ({ ...v, name: k }))
} }
}, },
created () { created () {
@ -42,6 +43,22 @@ const TimelineMenu = {
useListsMenu () { useListsMenu () {
const route = this.$route.name const route = this.$route.name
return route === 'lists-timeline' return route === 'lists-timeline'
},
...mapState({
currentUser: state => state.users.currentUser,
privateMode: state => state.instance.private,
federating: state => state.instance.federating
}),
timelinesList () {
return filterNavigation(
Object.entries(TIMELINES).map(([k, v]) => ({ ...v, name: k })),
{
hasChats: this.pleromaChatMessagesAvailable,
isFederating: this.federating,
isPrivate: this.privateMode,
currentUser: this.currentUser
}
)
} }
}, },
methods: { methods: {