fix: get server name from acct

This commit is contained in:
三咲智子 2022-12-04 15:18:11 +08:00
parent 218aefeec1
commit 7760d03f9d
No known key found for this signature in database
GPG key ID: 69992F2250DFD93E

View file

@ -28,10 +28,6 @@ export const STATUS_VISIBILITIES = [
}, },
] as const ] as const
export function getServerName(account: Account) {
return account.url.match(UserLinkRE)?.[1] || currentUser.value?.server || ''
}
export function getDisplayName(account?: Account, options?: { rich?: boolean }) { export function getDisplayName(account?: Account, options?: { rich?: boolean }) {
const displayName = account?.displayName || account?.username || '' const displayName = account?.displayName || account?.username || ''
if (options?.rich) if (options?.rich)
@ -45,6 +41,12 @@ export function getShortHandle({ acct }: Account) {
return `@${acct.includes('@') ? acct.split('@')[0] : acct}` return `@${acct.includes('@') ? acct.split('@')[0] : acct}`
} }
export function getServerName(account: Account) {
if (account.acct.includes('@'))
return account.acct.split('@')[1]
return account.url.match(UserLinkRE)?.[1] || currentUser.value?.server || ''
}
export function getFullHandle(account: Account) { export function getFullHandle(account: Account) {
const handle = `@${account.acct}` const handle = `@${account.acct}`
if (!currentUser.value || account.acct.includes('@')) if (!currentUser.value || account.acct.includes('@'))