From d0f4721925d0c50340d6db8a4e9f4d3e4ca01457 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Tue, 30 May 2023 09:03:51 +0200 Subject: [PATCH] fix(front): fix showing current identity avatar & banners Signed-off-by: Thomas Citharel --- .../views/Account/children/EditIdentity.vue | 43 ++++++++++--------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/js/src/views/Account/children/EditIdentity.vue b/js/src/views/Account/children/EditIdentity.vue index 22b26c6ad..93cdfc372 100644 --- a/js/src/views/Account/children/EditIdentity.vue +++ b/js/src/views/Account/children/EditIdentity.vue @@ -215,7 +215,7 @@ import { IPerson, displayName } from "@/types/actor"; import PictureUpload from "@/components/PictureUpload.vue"; import { MOBILIZON_INSTANCE_HOST } from "@/api/_entrypoint"; import RouteName from "@/router/name"; -import { buildFileVariable } from "@/utils/image"; +import { buildFileFromIMedia, buildFileVariable } from "@/utils/image"; import { changeIdentity } from "@/utils/identity"; import { CREATE_FEED_TOKEN_ACTOR, @@ -237,6 +237,7 @@ import { Dialog } from "@/plugins/dialog"; import { Notifier } from "@/plugins/notifier"; import { AbsintheGraphQLErrors } from "@/types/errors.model"; import { ICurrentUser } from "@/types/current-user.model"; +import { useHead } from "@vueuse/head"; const { t } = useI18n({ useScope: "global" }); const router = useRouter(); @@ -245,7 +246,11 @@ const props = defineProps<{ isUpdate: boolean; identityName?: string }>(); const { currentActor } = useCurrentActorClient(); -const { result: personResult, onError: onPersonError } = useQuery<{ +const { + result: personResult, + onError: onPersonError, + onResult: onPersonResult, +} = useQuery<{ fetchPerson: IPerson; }>( FETCH_PERSON, @@ -257,6 +262,10 @@ const { result: personResult, onError: onPersonError } = useQuery<{ }) ); +onPersonResult(async ({ data }) => { + avatarFile.value = await buildFileFromIMedia(data?.fetchPerson?.avatar); +}); + onPersonError((err) => handleErrors(err as unknown as AbsintheGraphQLErrors)); const person = computed(() => personResult.value?.fetchPerson); @@ -285,24 +294,6 @@ watch(person, () => { const avatarMaxSize = useAvatarMaxSize(); -// error({ graphQLErrors }) { -// this.handleErrors(graphQLErrors); -// }, -// metaInfo() { -// // eslint-disable-next-line @typescript-eslint/ban-ts-comment -// // @ts-ignore -// const { isUpdate, identityName } = this; -// let title = t("Create a new profile") as string; -// if (isUpdate) { -// title = t("Edit profile {profile}", { -// profile: identityName, -// }) as string; -// } -// return { -// title, -// }; -// }, - const errors = ref([]); const avatarFile = ref(null); const showCopiedTooltip = reactive({ ics: false, atom: false }); @@ -764,4 +755,16 @@ const breadcrumbsLinks = computed( const updateUsername = (value: string) => { identity.value.preferredUsername = convertToUsername(value); }; + +useHead({ + title: computed(() => { + let title = t("Create a new profile") as string; + if (isUpdate.value) { + title = t("Edit profile {profile}", { + profile: identityName.value, + }) as string; + } + return title; + }), +});