Show "Alias" badge on profile page if account has aliases

This commit is contained in:
silverpill 2023-02-27 00:17:30 +00:00
parent 177639614a
commit 2984d369a1
3 changed files with 26 additions and 0 deletions

View file

@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [Unreleased] ## [Unreleased]
### Added
- Show "Alias" badge on profile page if account has aliases.
### Changed ### Changed
- Use `/feeds/users/{username}` path for user's Atom feed. - Use `/feeds/users/{username}` path for user's Atom feed.

View file

@ -352,3 +352,13 @@ export async function createIdentityProof(
return data return data
} }
} }
export async function getAliases(profileId: string): Promise<Profile[]> {
const url = `${BACKEND_URL}/api/v1/accounts/${profileId}/aliases`
const response = await http(url)
const data = await response.json()
if (response.status !== 200) {
throw new Error(data.error_description)
}
return data
}

View file

@ -13,6 +13,13 @@
<div class="avatar-group"> <div class="avatar-group">
<avatar :profile="profile"></avatar> <avatar :profile="profile"></avatar>
<div class="badges"> <div class="badges">
<div
class="badge"
v-if="aliases.length > 0"
:title="aliases.map(profile => '@' + profile.acct).join(', ')"
>
Alias
</div>
<div class="badge" v-if="isFollowedBy()">Follows you</div> <div class="badge" v-if="isFollowedBy()">Follows you</div>
<div class="badge" v-if="isSubscriptionValid()">Subscription</div> <div class="badge" v-if="isSubscriptionValid()">Subscription</div>
<div class="badge" v-if="isSubscriber()">Subscriber</div> <div class="badge" v-if="isSubscriber()">Subscriber</div>
@ -257,6 +264,7 @@ import {
} from "@/api/relationships" } from "@/api/relationships"
import { getReceivedSubscriptions } from "@/api/subscriptions-common" import { getReceivedSubscriptions } from "@/api/subscriptions-common"
import { import {
getAliases,
getProfile, getProfile,
lookupProfile, lookupProfile,
Permissions, Permissions,
@ -288,6 +296,7 @@ const { instance, getActorAddress } = $(useInstanceInfo())
let profile = $ref<ProfileWrapper | null>(null) let profile = $ref<ProfileWrapper | null>(null)
let relationship = $ref<Relationship | null>(null) let relationship = $ref<Relationship | null>(null)
let aliases = $ref<Profile[]>([])
let profileMenuVisible = $ref(false) let profileMenuVisible = $ref(false)
@ -327,6 +336,9 @@ onMounted(async () => {
profile.id, profile.id,
) )
} }
if (profile.identity_proofs.length > 0) {
aliases = await getAliases(profile.id)
}
await switchTab("posts") await switchTab("posts")
isLoading = false isLoading = false
}) })