2023-01-08 06:21:09 +00:00
|
|
|
import type { mastodon } from 'masto'
|
2024-09-30 09:11:56 +01:00
|
|
|
import { withoutProtocol } from 'ufo'
|
2023-01-06 18:40:15 +00:00
|
|
|
|
2023-01-08 06:21:09 +00:00
|
|
|
export function getAccountRoute(account: mastodon.v1.Account) {
|
2023-01-06 18:40:15 +00:00
|
|
|
return useRouter().resolve({
|
|
|
|
name: 'account-index',
|
|
|
|
params: {
|
|
|
|
server: currentServer.value,
|
|
|
|
account: extractAccountHandle(account),
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
2023-01-08 06:21:09 +00:00
|
|
|
export function getAccountFollowingRoute(account: mastodon.v1.Account) {
|
2023-01-06 18:40:15 +00:00
|
|
|
return useRouter().resolve({
|
|
|
|
name: 'account-following',
|
|
|
|
params: {
|
|
|
|
server: currentServer.value,
|
|
|
|
account: extractAccountHandle(account),
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
2023-01-08 06:21:09 +00:00
|
|
|
export function getAccountFollowersRoute(account: mastodon.v1.Account) {
|
2023-01-06 18:40:15 +00:00
|
|
|
return useRouter().resolve({
|
|
|
|
name: 'account-followers',
|
|
|
|
params: {
|
|
|
|
server: currentServer.value,
|
|
|
|
account: extractAccountHandle(account),
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2023-05-03 16:01:35 +01:00
|
|
|
export function getReportRoute(id: string | number) {
|
|
|
|
return `https://${currentUser.value?.server}/admin/reports/${encodeURIComponent(id)}`
|
|
|
|
}
|
|
|
|
|
2023-01-08 06:21:09 +00:00
|
|
|
export function getStatusRoute(status: mastodon.v1.Status) {
|
2023-01-06 18:40:15 +00:00
|
|
|
return useRouter().resolve({
|
|
|
|
name: 'status',
|
|
|
|
params: {
|
|
|
|
server: currentServer.value,
|
|
|
|
account: extractAccountHandle(status.account),
|
|
|
|
status: status.id,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
export function getTagRoute(tag: string) {
|
|
|
|
return useRouter().resolve({
|
|
|
|
name: 'tag',
|
|
|
|
params: {
|
|
|
|
server: currentServer.value,
|
|
|
|
tag,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2023-01-08 06:21:09 +00:00
|
|
|
export function getStatusPermalinkRoute(status: mastodon.v1.Status) {
|
2023-01-06 18:40:15 +00:00
|
|
|
return status.url ? withoutProtocol(status.url) : null
|
|
|
|
}
|
|
|
|
|
2023-01-08 06:21:09 +00:00
|
|
|
export function getStatusInReplyToRoute(status: mastodon.v1.Status) {
|
2023-01-06 18:40:15 +00:00
|
|
|
return useRouter().resolve({
|
|
|
|
name: 'status-by-id',
|
|
|
|
params: {
|
|
|
|
server: currentServer.value,
|
|
|
|
status: status.inReplyToId,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
2023-01-10 13:22:39 +00:00
|
|
|
|
2023-03-30 20:01:24 +01:00
|
|
|
export function navigateToStatus({ status, focusReply = false }: {
|
2023-01-10 13:22:39 +00:00
|
|
|
status: mastodon.v1.Status
|
|
|
|
focusReply?: boolean
|
2023-03-30 20:01:24 +01:00
|
|
|
}) {
|
|
|
|
return navigateTo({
|
2023-01-10 13:22:39 +00:00
|
|
|
path: getStatusRoute(status).href,
|
|
|
|
state: { focusReply },
|
|
|
|
})
|
2023-03-30 20:01:24 +01:00
|
|
|
}
|