fix: account followers and following links (#519)

zio/stable
Joaquín Sánchez 2022-12-22 21:15:06 +01:00 committed by GitHub
parent fef082af13
commit 4d8b402b04
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 5 deletions

View File

@ -63,17 +63,21 @@ export function toShortHandle(fullHandle: string) {
return fullHandle return fullHandle
} }
export function getAccountRoute(account: Account) { export function extractAccountHandle(account: Account) {
let handle = getFullHandle(account).slice(1) let handle = getFullHandle(account).slice(1)
const uri = currentInstance.value?.uri ?? currentServer.value const uri = currentInstance.value?.uri ?? currentServer.value
if (currentInstance.value && handle.endsWith(`@${uri}`)) if (currentInstance.value && handle.endsWith(`@${uri}`))
handle = handle.slice(0, -uri.length - 1) handle = handle.slice(0, -uri.length - 1)
return handle
}
export function getAccountRoute(account: Account) {
return useRouter().resolve({ return useRouter().resolve({
name: 'account-index', name: 'account-index',
params: { params: {
server: currentServer.value, server: currentServer.value,
account: handle, account: extractAccountHandle(account),
}, },
state: { state: {
account: account as any, account: account as any,
@ -85,7 +89,7 @@ export function getAccountFollowingRoute(account: Account) {
name: 'account-following', name: 'account-following',
params: { params: {
server: currentServer.value, server: currentServer.value,
account: getFullHandle(account).slice(1), account: extractAccountHandle(account),
}, },
state: { state: {
account: account as any, account: account as any,
@ -97,7 +101,7 @@ export function getAccountFollowersRoute(account: Account) {
name: 'account-followers', name: 'account-followers',
params: { params: {
server: currentServer.value, server: currentServer.value,
account: getFullHandle(account).slice(1), account: extractAccountHandle(account),
}, },
state: { state: {
account: account as any, account: account as any,
@ -110,7 +114,7 @@ export function getStatusRoute(status: Status) {
name: 'status', name: 'status',
params: { params: {
server: currentServer.value, server: currentServer.value,
account: getFullHandle(status.account).slice(1), account: extractAccountHandle(status.account),
status: status.id, status: status.id,
}, },
state: { state: {