refactor: getAccountHandle, getAccountPath, getStatusPath

This commit is contained in:
patak 2022-11-23 23:40:35 +01:00
parent 713617e19a
commit f596973603
8 changed files with 26 additions and 14 deletions

View file

@ -1,10 +1,22 @@
import type { Ref } from 'vue'
import type { Account, Relationship } from 'masto'
import type { Account, Relationship, Status } from 'masto'
export function getDisplayName(account: Account) {
return account.displayName || account.username
}
export function getAccountHandle(account: Account) {
return `@${account.acct}`
}
export function getAccountPath(account: Account) {
return `/${getAccountHandle(account)}`
}
export function getStatusPath(status: Status) {
return `${getAccountPath(status.account)}/${status.id}`
}
// Batch requests for relationships when used in the UI
// We don't want to hold to old values, so every time a Relationship is needed it
// is requested again from the server to show the latest state