fix: refresh status after edit (#2032)

zio/stable
Alex 2023-04-30 23:19:14 +08:00 committed by GitHub
parent c7b77216c1
commit ccf115ca4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 3 deletions

View File

@ -7,6 +7,10 @@ const props = defineProps<{
command?: boolean
}>()
const emit = defineEmits<{
(event: 'afterEdit'): void
}>()
const { details, command } = $(props)
const {
@ -101,10 +105,11 @@ function reply() {
}
async function editStatus() {
openPublishDialog(`edit-${status.id}`, {
await openPublishDialog(`edit-${status.id}`, {
...await getDraftFromStatus(status),
editingStatus: status,
}, true)
emit('afterEdit')
}
function showFavoritedAndBoostedBy() {

View File

@ -10,6 +10,10 @@ const props = withDefaults(defineProps<{
actions: true,
})
defineEmits<{
(event: 'refetchStatus'): void
}>()
const status = $computed(() => {
if (props.status.reblog && props.status.reblog)
return props.status.reblog
@ -27,7 +31,7 @@ useHydratedHead({
<template>
<div :id="`status-${status.id}`" flex flex-col gap-2 pt2 pb1 ps-3 pe-4 relative :lang="status.language ?? undefined" aria-roledescription="status-details">
<StatusActionsMore :status="status" absolute inset-ie-2 top-2 />
<StatusActionsMore :status="status" absolute inset-ie-2 top-2 @after-edit="$emit('refetchStatus')" />
<NuxtLink :to="getAccountRoute(status.account)" rounded-full hover:bg-active transition-100 pe5 me-a>
<AccountHoverWrapper :account="status.account">
<AccountInfo :account="status.account" />

View File

@ -16,7 +16,7 @@ const main = ref<ComponentPublicInstance | null>(null)
const { data: status, pending, refresh: refreshStatus } = useAsyncData(
`status:${id}`,
() => fetchStatus(id),
() => fetchStatus(id, true),
{ watch: [isHydrated], immediate: isHydrated.value, default: () => shallowRef() },
)
const { client } = $(useMasto())
@ -83,6 +83,7 @@ onReactivated(() => {
:newer="context?.ancestors.at(-1)"
command
style="scroll-margin-top: 60px"
@refetch-status="refreshStatus()"
/>
<PublishWidget
v-if="currentUser"