1
0
Fork 1
mirror of https://github.com/elk-zone/elk.git synced 2024-11-20 07:49:57 +00:00

fix: handle no acct string

This commit is contained in:
Daniel Roe 2022-12-28 17:01:13 +01:00
parent abe6af40f3
commit 34dc2f7736
No known key found for this signature in database
GPG key ID: 22D5008E4F5D9B55
2 changed files with 3 additions and 3 deletions

View file

@ -44,7 +44,7 @@ export function fetchAccountById(id?: string | null): Promise<Account | null> {
const uri = currentInstance.value?.uri const uri = currentInstance.value?.uri
const promise = useMasto().accounts.fetch(id) const promise = useMasto().accounts.fetch(id)
.then((r) => { .then((r) => {
if (!r.acct.includes('@') && uri) if (r.acct && !r.acct.includes('@') && uri)
r.acct = `${r.acct}@${uri}` r.acct = `${r.acct}@${uri}`
cacheAccount(r, server, true) cacheAccount(r, server, true)
@ -63,7 +63,7 @@ export async function fetchAccountByHandle(acct: string): Promise<Account> {
const uri = currentInstance.value?.uri const uri = currentInstance.value?.uri
const account = useMasto().accounts.lookup({ acct }) const account = useMasto().accounts.lookup({ acct })
.then((r) => { .then((r) => {
if (!r.acct.includes('@') && uri) if (r.acct && !r.acct.includes('@') && uri)
r.acct = `${r.acct}@${uri}` r.acct = `${r.acct}@${uri}`
cacheAccount(r, server, true) cacheAccount(r, server, true)

View file

@ -41,7 +41,7 @@ export function getShortHandle({ acct }: Account) {
} }
export function getServerName(account: Account) { export function getServerName(account: Account) {
if (account.acct.includes('@')) if (account.acct?.includes('@'))
return account.acct.split('@')[1] return account.acct.split('@')[1]
// We should only lack the server name if we're on the same server as the account // We should only lack the server name if we're on the same server as the account
return currentInstance.value?.uri || '' return currentInstance.value?.uri || ''