From dcb24e900d0894cbfa079dde083d1de92b1f213a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Buget?= Date: Wed, 20 Sep 2023 10:39:05 +0200 Subject: [PATCH] fix: thread summaries now refresh well when thread status has changed --- components/ThreadEditor.vue | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/components/ThreadEditor.vue b/components/ThreadEditor.vue index f01a232..be13f02 100644 --- a/components/ThreadEditor.vue +++ b/components/ThreadEditor.vue @@ -117,7 +117,6 @@ async function doSaveThread(thread: Thread): Promise { url += `/${thread.id}` } const response: any = await $fetch(url, { method: 'post', body: { messages: thread.messages } }) - emit('thread-saved') changeUpdateKey() return response.id as number } @@ -126,6 +125,7 @@ async function saveThread(): Promise { try { if (thread.value && thread.value.messages) { thread.value.id = await doSaveThread(thread.value) + emit('thread-saved') toast.add({ severity: 'success', summary: 'Thread saved', detail: `${thread.value.messages.length} posts saved`, life: 3000 }); } } catch (err: any) { @@ -139,6 +139,7 @@ async function publishThread(): Promise { thread.value.id = await doSaveThread(thread.value) const nonEmptyMessages = thread.value.messages.filter((message: any) => message.text.trim().length > 0 || message.attachments.length > 0) await $fetch(`/api/threads/${thread.value.id}/publication`, { method: 'post' }) + emit('thread-saved') toast.add({ severity: 'success', summary: 'Thread published', detail: `${nonEmptyMessages.length} posts published`, life: 3000 }); } } catch (err: any) { @@ -156,6 +157,7 @@ async function scheduleThread(): Promise { thread.value.scheduledAt = threadScheduleDate.value threadScheduleDialogVisible.value = false + emit('thread-saved') toast.add({ severity: 'success', summary: 'Thread scheduled', detail: `Publication scheduled`, life: 3000 }); } } catch (err: any) { @@ -169,6 +171,7 @@ async function cancelThreadSchedule(): Promise { await $fetch(`/api/threads/${thread.value.id}/schedule`, { method: 'delete' }) thread.value.scheduledAt = undefined changeUpdateKey() + emit('thread-saved') toast.add({ severity: 'success', summary: 'Thread schedule canceled', detail: `Publication canceled`, life: 3000 }); } } catch (err: any) {