diff --git a/components/account/AccountHeader.vue b/components/account/AccountHeader.vue index 9e9f9c7a4..496327e62 100644 --- a/components/account/AccountHeader.vue +++ b/components/account/AccountHeader.vue @@ -6,6 +6,8 @@ const { account } = defineProps<{ command?: boolean }>() +const masto = useMasto() + const { t } = useI18n() const createdAt = $(useFormattedDateTime(() => account.createdAt, { @@ -14,6 +16,8 @@ const createdAt = $(useFormattedDateTime(() => account.createdAt, { year: 'numeric', })) +const relationship = $(useRelationship(account)) + const namedFields = ref([]) const iconFields = ref([]) @@ -39,6 +43,21 @@ function previewAvatar() { }]) } +async function toggleNotify() { + // @ts-expect-error: Masto.js only recently added this field. Can be removed when Elk updates Masto.js to 5.4.0 or higher. + relationship!.notifying = !relationship?.notifying + try { + // @ts-expect-error: Masto.js only recently added this field. Can be removed when Elk updates Masto.js to 5.4.0 or higher. + const newRel = await masto.v1.accounts.follow(account.id, { notify: relationship?.notifying }) + Object.assign(relationship!, newRel) + } + catch { + // TODO error handling + // @ts-expect-error: Masto.js only recently added this field. Can be removed when Elk updates Masto.js to 5.4.0 or higher. + relationship!.notifying = !relationship?.notifying + } +} + watchEffect(() => { const named: mastodon.v1.AccountField[] = [] const icons: mastodon.v1.AccountField[] = [] @@ -60,6 +79,8 @@ watchEffect(() => { }) const isSelf = $computed(() => currentUser.value?.account.id === account.id) +// @ts-expect-error: Masto.js only recently added this field. Can be removed when Elk updates Masto.js to 5.4.0 or higher. +const isAlertedOnPost = $computed(() => relationship?.notifying)