diff --git a/CHANGELOG.md b/CHANGELOG.md index 307e1a4..99e24f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased] +### Changed + +- Use `/@username` routes by default. + ## [1.15.0] - 2023-02-27 ### Added diff --git a/src/api/users.ts b/src/api/users.ts index f424ca3..04c8aa7 100644 --- a/src/api/users.ts +++ b/src/api/users.ts @@ -121,8 +121,8 @@ export class ProfileWrapper { option.type === "monero-subscription" ) { return { - name: "profile-subscription", - params: { profileId: this.id }, + name: "profile-by-acct-subscription", + params: { acct: this.acct }, } } } diff --git a/src/components/Post.vue b/src/components/Post.vue index 817ea51..279810e 100644 --- a/src/components/Post.vue +++ b/src/components/Post.vue @@ -5,7 +5,7 @@ class="floating-avatar" :href="post.account.url" :title="author.getDisplayName()" - @click="openProfile($event, post.account.id)" + @click="openProfile($event, post.account)" > @@ -13,7 +13,7 @@ class="display-name" :href="post.account.url" :title="author.getDisplayName()" - @click="openProfile($event, post.account.id)" + @click="openProfile($event, post.account)" > {{ author.getDisplayName() }} @@ -53,7 +53,7 @@ :key="mention.id" :href="mention.url" :title="getActorAddress(mention)" - @click="openProfile($event, mention.id)" + @click="openProfile($event, mention)" > @{{ mention.username }} @@ -255,7 +255,11 @@ import { createRepost, deleteRepost, } from "@/api/posts" -import { Permissions, ProfileWrapper } from "@/api/users" +import { + Permissions, + Profile, + ProfileWrapper, +} from "@/api/users" import Avatar from "@/components/Avatar.vue" import CryptoAddress from "@/components/CryptoAddress.vue" import PostAttachment from "@/components/PostAttachment.vue" @@ -301,13 +305,13 @@ let isWaitingForToken = $ref(false) const blockchain = $computed(() => instance?.blockchains[0]) const author = $computed(() => new ProfileWrapper(props.post.account)) -function openProfile(event: Event, profileId: string) { +function openProfile(event: Event, profile: Mention | Profile) { if (currentUser === null) { // Viewing as guest; do not override click handler return } event.preventDefault() - router.push({ name: "profile", params: { profileId: profileId } }) + router.push({ name: "profile-by-acct", params: { acct: profile.acct } }) } function highlight(postId: string | null) { diff --git a/src/components/PostContent.vue b/src/components/PostContent.vue index 059a57c..022c20d 100644 --- a/src/components/PostContent.vue +++ b/src/components/PostContent.vue @@ -38,7 +38,7 @@ function configureInlineLinks() { if (mention) { mentionElement.addEventListener("click", (event: Event) => { event.preventDefault() - router.push({ name: "profile", params: { profileId: mention.id } }) + router.push({ name: "profile-by-acct", params: { acct: mention.acct } }) }) } } diff --git a/src/components/PostEditor.vue b/src/components/PostEditor.vue index 604e014..8960d74 100644 --- a/src/components/PostEditor.vue +++ b/src/components/PostEditor.vue @@ -3,7 +3,7 @@ diff --git a/src/components/PostOrRepost.vue b/src/components/PostOrRepost.vue index c5c1aef..7294ae8 100644 --- a/src/components/PostOrRepost.vue +++ b/src/components/PostOrRepost.vue @@ -3,7 +3,7 @@
{{ author.getDisplayName() }} diff --git a/src/components/SidebarLayout.vue b/src/components/SidebarLayout.vue index a35d6b0..3b7c50c 100644 --- a/src/components/SidebarLayout.vue +++ b/src/components/SidebarLayout.vue @@ -15,7 +15,7 @@
@{{ currentUser.username }}
diff --git a/src/components/SubscriptionEthereum.vue b/src/components/SubscriptionEthereum.vue index 23055bf..e353793 100644 --- a/src/components/SubscriptionEthereum.vue +++ b/src/components/SubscriptionEthereum.vue @@ -4,7 +4,7 @@
{{ sender.getDisplayName() }}
@@ -13,7 +13,10 @@
- +
{{ recipient.getDisplayName() }}
{{ recipientEthereumAddress }}
diff --git a/src/components/SubscriptionMonero.vue b/src/components/SubscriptionMonero.vue index 338c045..dcef7e0 100644 --- a/src/components/SubscriptionMonero.vue +++ b/src/components/SubscriptionMonero.vue @@ -4,7 +4,7 @@
{{ sender.getDisplayName() }}
@@ -12,7 +12,10 @@
- +
{{ recipient.getDisplayName() }}
diff --git a/src/components/SubscriptionSettingsMonero.vue b/src/components/SubscriptionSettingsMonero.vue index ea08bc7..c938d1e 100644 --- a/src/components/SubscriptionSettingsMonero.vue +++ b/src/components/SubscriptionSettingsMonero.vue @@ -110,8 +110,8 @@ async function loadSubscriptionSettings() { function getSubscriptionPagePath(): string { const route = router.resolve({ - name: "profile-subscription", - params: { profileId: ensureCurrentUser().id }, + name: "profile-by-acct-subscription", + params: { acct: ensureCurrentUser().acct }, }) return route.fullPath } diff --git a/src/router/index.ts b/src/router/index.ts index b75db6b..fd01d61 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -100,12 +100,24 @@ const routes: Array = [ component: ProfileView, meta: { }, }, + { + path: "/@:acct(.*)", + name: "profile-by-acct", + component: ProfileView, + meta: { }, + }, { path: "/profile/:profileId/subscription", name: "profile-subscription", component: SubscriptionPage, meta: { }, }, + { + path: "/@:acct(.*)/subscription", + name: "profile-by-acct-subscription", + component: SubscriptionPage, + meta: { }, + }, { path: "/profile-directory", name: "profile-directory", @@ -160,12 +172,6 @@ const routes: Array = [ .includes(Permissions.ManageSubscriptionOptions) }, }, - { - path: "/@:acct(.*)", - name: "profile-by-acct", - component: ProfileView, - meta: { }, - }, { path: "/:pathMatch(.*)*", redirect: { name: "home" }, diff --git a/src/views/IdentityProof.vue b/src/views/IdentityProof.vue index 9be7853..f1bc082 100644 --- a/src/views/IdentityProof.vue +++ b/src/views/IdentityProof.vue @@ -67,7 +67,7 @@ async function submit() { did, signature, ) - router.push({ name: "profile", params: { profileId: currentUser.id } }) + router.push({ name: "profile-by-acct", params: { acct: currentUser.acct } }) } } diff --git a/src/views/ImportFollows.vue b/src/views/ImportFollows.vue index 090aaed..04e476f 100644 --- a/src/views/ImportFollows.vue +++ b/src/views/ImportFollows.vue @@ -61,7 +61,7 @@ async function submit() { } isLoading = false errorMessage = null - router.push({ name: "profile", params: { profileId: currentUser.id } }) + router.push({ name: "profile-by-acct", params: { acct: currentUser.acct } }) } diff --git a/src/views/MoveFollowers.vue b/src/views/MoveFollowers.vue index 34945e7..337e6e1 100644 --- a/src/views/MoveFollowers.vue +++ b/src/views/MoveFollowers.vue @@ -73,7 +73,7 @@ async function move() { isLoading = false errorMessage = null setCurrentUser(user) - router.push({ name: "profile", params: { profileId: currentUser.id } }) + router.push({ name: "profile-by-acct", params: { acct: currentUser.acct } }) } diff --git a/src/views/NotificationList.vue b/src/views/NotificationList.vue index 1c9fcf7..799f2dd 100644 --- a/src/views/NotificationList.vue +++ b/src/views/NotificationList.vue @@ -19,7 +19,7 @@ {{ getSenderName(notification) }} @@ -42,7 +42,7 @@
diff --git a/src/views/PostOverlay.vue b/src/views/PostOverlay.vue index add0f84..1208b43 100644 --- a/src/views/PostOverlay.vue +++ b/src/views/PostOverlay.vue @@ -13,7 +13,10 @@
- +
@{{ actorAddress }}
diff --git a/src/views/Profile.vue b/src/views/Profile.vue index 412788f..457622f 100644 --- a/src/views/Profile.vue +++ b/src/views/Profile.vue @@ -231,7 +231,7 @@ diff --git a/src/views/ProfileDirectory.vue b/src/views/ProfileDirectory.vue index 27c71e2..793ad73 100644 --- a/src/views/ProfileDirectory.vue +++ b/src/views/ProfileDirectory.vue @@ -5,7 +5,7 @@ diff --git a/src/views/ProfileForm.vue b/src/views/ProfileForm.vue index c4f3cc8..f4ea0e5 100644 --- a/src/views/ProfileForm.vue +++ b/src/views/ProfileForm.vue @@ -217,7 +217,7 @@ async function save() { } isLoading = false setCurrentUser(user) - router.push({ name: "profile", params: { profileId: user.id } }) + router.push({ name: "profile-by-acct", params: { acct: user.acct } }) } diff --git a/src/views/SearchResultList.vue b/src/views/SearchResultList.vue index e13592c..ba7573d 100644 --- a/src/views/SearchResultList.vue +++ b/src/views/SearchResultList.vue @@ -14,7 +14,7 @@ class="search-result" v-for="profile in profiles" :key="profile.id" - :to="{ name: 'profile', params: { profileId: profile.id } }" + :to="{ name: 'profile-by-acct', params: { acct: profile.acct } }" > diff --git a/src/views/SubscriptionPage.vue b/src/views/SubscriptionPage.vue index 470be10..53f8a34 100644 --- a/src/views/SubscriptionPage.vue +++ b/src/views/SubscriptionPage.vue @@ -13,7 +13,11 @@ import { onMounted } from "vue" import { $, $computed, $ref } from "vue/macros" import { useRoute } from "vue-router" -import { getProfile, Profile } from "@/api/users" +import { + lookupProfile, + getProfile, + Profile, +} from "@/api/users" import SidebarLayout from "@/components/SidebarLayout.vue" import SubscriptionEthereum from "@/components/SubscriptionEthereum.vue" import SubscriptionMonero from "@/components/SubscriptionMonero.vue" @@ -29,10 +33,17 @@ const blockchain = $computed(() => instance?.blockchains[0]) onMounted(async () => { // Recipient - profile = await getProfile( - authToken, - route.params.profileId as string, - ) + if (route.params.acct) { + profile = await lookupProfile( + authToken, + route.params.acct as string, + ) + } else { + profile = await getProfile( + authToken, + route.params.profileId as string, + ) + } }) function isLocalUser(): boolean {