biome format --write

This commit is contained in:
Henry Jameson 2026-01-06 16:22:52 +02:00
commit 9262e803ec
415 changed files with 54076 additions and 17419 deletions

View file

@ -1,39 +1,50 @@
export const filterNavigation = (list = [], {
hasChats,
hasAnnouncements,
isFederating,
isPrivate,
currentUser,
supportsBookmarkFolders,
supportsBubbleTimeline
}) => {
export const filterNavigation = (
list = [],
{
hasChats,
hasAnnouncements,
isFederating,
isPrivate,
currentUser,
supportsBookmarkFolders,
supportsBubbleTimeline,
},
) => {
return list.filter(({ criteria, anon, anonRoute }) => {
const set = new Set(criteria || [])
if (!isFederating && set.has('federating')) return false
if (!currentUser && isPrivate && set.has('!private')) 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 (!hasAnnouncements && set.has('announcements')) return false
if (!supportsBubbleTimeline && set.has('supportsBubbleTimeline')) return false
if (!supportsBookmarkFolders && set.has('supportsBookmarkFolders')) return false
if (supportsBookmarkFolders && set.has('!supportsBookmarkFolders')) return false
if (!supportsBubbleTimeline && set.has('supportsBubbleTimeline'))
return false
if (!supportsBookmarkFolders && set.has('supportsBookmarkFolders'))
return false
if (supportsBookmarkFolders && set.has('!supportsBookmarkFolders'))
return false
return true
})
}
export const getListEntries = store => store.allLists.map(list => ({
name: 'list-' + list.id,
routeObject: { name: 'lists-timeline', params: { id: list.id } },
labelRaw: list.title,
iconLetter: list.title[0]
}))
export const getListEntries = (store) =>
store.allLists.map((list) => ({
name: 'list-' + list.id,
routeObject: { name: 'lists-timeline', params: { id: list.id } },
labelRaw: list.title,
iconLetter: list.title[0],
}))
export const getBookmarkFolderEntries = store => store.allFolders ? store.allFolders.map(folder => ({
name: 'bookmark-folder-' + folder.id,
routeObject: { name: 'bookmark-folder', params: { id: folder.id } },
labelRaw: folder.name,
iconEmoji: folder.emoji,
iconEmojiUrl: folder.emoji_url,
iconLetter: folder.name[0]
})) : []
export const getBookmarkFolderEntries = (store) =>
store.allFolders
? store.allFolders.map((folder) => ({
name: 'bookmark-folder-' + folder.id,
routeObject: { name: 'bookmark-folder', params: { id: folder.id } },
labelRaw: folder.name,
iconEmoji: folder.emoji,
iconEmojiUrl: folder.emoji_url,
iconLetter: folder.name[0],
}))
: []

View file

@ -4,42 +4,39 @@ export const USERNAME_ROUTES = new Set([
'interactions',
'notifications',
'chat',
'chats'
'chats',
])
// routes that take :name property
export const NAME_ROUTES = new Set([
'user-profile',
'legacy-user-profile'
])
export const NAME_ROUTES = new Set(['user-profile', 'legacy-user-profile'])
export const TIMELINES = {
home: {
route: 'friends',
icon: 'home',
label: 'nav.home_timeline',
criteria: ['!private']
criteria: ['!private'],
},
public: {
route: 'public-timeline',
anon: true,
icon: 'users',
label: 'nav.public_tl',
criteria: ['!private']
criteria: ['!private'],
},
bubble: {
route: 'bubble',
anon: true,
icon: 'city',
label: 'nav.bubble',
criteria: ['!private', 'federating', 'supportsBubbleTimeline']
criteria: ['!private', 'federating', 'supportsBubbleTimeline'],
},
twkn: {
route: 'public-external-timeline',
anon: true,
icon: 'globe',
label: 'nav.twkn',
criteria: ['!private', 'federating']
criteria: ['!private', 'federating'],
},
// bookmarks are still technically a timeline so we should show it in the dropdown
bookmarks: {
@ -50,13 +47,13 @@ export const TIMELINES = {
favorites: {
routeObject: { name: 'user-profile', query: { tab: 'favorites' } },
icon: 'star',
label: 'user_card.favorites'
label: 'user_card.favorites',
},
dms: {
route: 'dms',
icon: 'envelope',
label: 'nav.dms'
}
label: 'nav.dms',
},
}
export const ROOT_ITEMS = {
@ -67,12 +64,12 @@ export const ROOT_ITEMS = {
// shows bookmarks entry in a better suited location
// hides it when bookmark folders are supported since
// we show custom component instead of it
criteria: ['!supportsBookmarkFolders']
criteria: ['!supportsBookmarkFolders'],
},
interactions: {
route: 'interactions',
icon: 'bell',
label: 'nav.interactions'
label: 'nav.interactions',
},
chats: {
route: 'chats',
@ -80,7 +77,7 @@ export const ROOT_ITEMS = {
label: 'nav.chats',
badgeStyle: 'notification',
badgeGetter: 'unreadChatCount',
criteria: ['chats']
criteria: ['chats'],
},
friendRequests: {
route: 'friend-requests',
@ -88,13 +85,13 @@ export const ROOT_ITEMS = {
label: 'nav.friend_requests',
badgeStyle: 'notification',
criteria: ['lockedUser'],
badgeGetter: 'followRequestCount'
badgeGetter: 'followRequestCount',
},
about: {
route: 'about',
anon: true,
icon: 'info-circle',
label: 'nav.about'
label: 'nav.about',
},
announcements: {
route: 'announcements',
@ -103,18 +100,18 @@ export const ROOT_ITEMS = {
store: 'announcements',
badgeStyle: 'notification',
badgeGetter: 'unreadAnnouncementCount',
criteria: ['announcements']
criteria: ['announcements'],
},
drafts: {
route: 'drafts',
icon: 'file-pen',
label: 'nav.drafts',
badgeStyle: 'neutral',
badgeGetter: 'draftCount'
}
badgeGetter: 'draftCount',
},
}
export function routeTo (item, currentUser) {
export function routeTo(item, currentUser) {
if (!item.route && !item.routeObject) return null
let route
@ -122,7 +119,7 @@ export function routeTo (item, currentUser) {
if (item.routeObject) {
route = item.routeObject
} else {
route = { name: (item.anon || currentUser) ? item.route : item.anonRoute }
route = { name: item.anon || currentUser ? item.route : item.anonRoute }
}
if (USERNAME_ROUTES.has(route.name)) {

View file

@ -13,36 +13,43 @@ library.add(faThumbtack)
const NavigationEntry = {
props: ['item', 'showPin'],
components: {
OptionalRouterLink
OptionalRouterLink,
},
methods: {
isPinned (value) {
isPinned(value) {
return this.pinnedItems.has(value)
},
togglePin (value) {
togglePin(value) {
if (this.isPinned(value)) {
useServerSideStorageStore().removeCollectionPreference({ path: 'collections.pinnedNavItems', value })
useServerSideStorageStore().removeCollectionPreference({
path: 'collections.pinnedNavItems',
value,
})
} else {
useServerSideStorageStore().addCollectionPreference({ path: 'collections.pinnedNavItems', value })
useServerSideStorageStore().addCollectionPreference({
path: 'collections.pinnedNavItems',
value,
})
}
useServerSideStorageStore().pushServerSideStorage()
}
},
},
computed: {
routeTo () {
routeTo() {
return routeTo(this.item, this.currentUser)
},
getters () {
getters() {
return this.$store.getters
},
...mapStores(useAnnouncementsStore),
...mapState({
currentUser: state => state.users.currentUser
currentUser: (state) => state.users.currentUser,
}),
...mapPiniaState(useServerSideStorageStore, {
pinnedItems: store => new Set(store.prefsStorage.collections.pinnedNavItems)
pinnedItems: (store) =>
new Set(store.prefsStorage.collections.pinnedNavItems),
}),
}
},
}
export default NavigationEntry

View file

@ -1,7 +1,15 @@
import { mapState } from 'vuex'
import { mapState as mapPiniaState } from 'pinia'
import { TIMELINES, ROOT_ITEMS, routeTo } from 'src/components/navigation/navigation.js'
import { getBookmarkFolderEntries, getListEntries, filterNavigation } from 'src/components/navigation/filter.js'
import {
TIMELINES,
ROOT_ITEMS,
routeTo,
} from 'src/components/navigation/navigation.js'
import {
getBookmarkFolderEntries,
getListEntries,
filterNavigation,
} from 'src/components/navigation/filter.js'
import StillImage from 'src/components/still-image/still-image.vue'
@ -16,7 +24,7 @@ import {
faBell,
faInfoCircle,
faStream,
faList
faList,
} from '@fortawesome/free-solid-svg-icons'
import { useListsStore } from 'src/stores/lists'
import { useAnnouncementsStore } from 'src/stores/announcements'
@ -33,72 +41,74 @@ library.add(
faBell,
faInfoCircle,
faStream,
faList
faList,
)
const NavPanel = {
props: ['limit'],
methods: {
getRouteTo (item) {
getRouteTo(item) {
return routeTo(item, this.currentUser)
}
},
},
components: {
StillImage
StillImage,
},
computed: {
getters () {
getters() {
return this.$store.getters
},
...mapPiniaState(useListsStore, {
lists: getListEntries
lists: getListEntries,
}),
...mapPiniaState(useAnnouncementsStore, {
supportsAnnouncements: store => store.supportsAnnouncements
supportsAnnouncements: (store) => store.supportsAnnouncements,
}),
...mapPiniaState(useBookmarkFoldersStore, {
bookmarks: getBookmarkFolderEntries,
}),
...mapPiniaState(useServerSideStorageStore, {
pinnedItems: store => new Set(store.prefsStorage.collections.pinnedNavItems)
pinnedItems: (store) =>
new Set(store.prefsStorage.collections.pinnedNavItems),
}),
...mapState({
currentUser: state => state.users.currentUser,
followRequestCount: state => state.api.followRequests.length,
privateMode: state => state.instance.private,
federating: state => state.instance.federating,
pleromaChatMessagesAvailable: state => state.instance.pleromaChatMessagesAvailable,
bubbleTimeline: state => state.instance.localBubbleInstances.length > 0
currentUser: (state) => state.users.currentUser,
followRequestCount: (state) => state.api.followRequests.length,
privateMode: (state) => state.instance.private,
federating: (state) => state.instance.federating,
pleromaChatMessagesAvailable: (state) =>
state.instance.pleromaChatMessagesAvailable,
bubbleTimeline: (state) => state.instance.localBubbleInstances.length > 0,
}),
pinnedList () {
pinnedList() {
if (!this.currentUser) {
return filterNavigation([
{ ...TIMELINES.public, name: 'public' },
{ ...TIMELINES.twkn, name: 'twkn' },
{ ...ROOT_ITEMS.about, name: 'about' }
],
{
hasChats: this.pleromaChatMessagesAvailable,
hasAnnouncements: this.supportsAnnouncements,
isFederating: this.federating,
isPrivate: this.privateMode,
currentUser: this.currentUser,
supportsBubbleTimeline: this.bubbleTimeline,
supportsBookmarkFolders: this.bookmarks
})
return filterNavigation(
[
{ ...TIMELINES.public, name: 'public' },
{ ...TIMELINES.twkn, name: 'twkn' },
{ ...ROOT_ITEMS.about, name: 'about' },
],
{
hasChats: this.pleromaChatMessagesAvailable,
hasAnnouncements: this.supportsAnnouncements,
isFederating: this.federating,
isPrivate: this.privateMode,
currentUser: this.currentUser,
supportsBubbleTimeline: this.bubbleTimeline,
supportsBookmarkFolders: this.bookmarks,
},
)
}
return filterNavigation(
[
...Object
.entries({ ...TIMELINES })
...Object.entries({ ...TIMELINES })
.filter(([k]) => this.pinnedItems.has(k))
.map(([k, v]) => ({ ...v, name: k })),
...this.lists.filter((k) => this.pinnedItems.has(k.name)),
...this.bookmarks.filter((k) => this.pinnedItems.has(k.name)),
...Object
.entries({ ...ROOT_ITEMS })
...Object.entries({ ...ROOT_ITEMS })
.filter(([k]) => this.pinnedItems.has(k))
.map(([k, v]) => ({ ...v, name: k }))
.map(([k, v]) => ({ ...v, name: k })),
],
{
hasChats: this.pleromaChatMessagesAvailable,
@ -107,11 +117,11 @@ const NavPanel = {
supportsBookmarkFolders: this.bookmarks,
isFederating: this.federating,
isPrivate: this.privateMode,
currentUser: this.currentUser
}
currentUser: this.currentUser,
},
).slice(0, this.limit)
}
}
},
},
}
export default NavPanel