From e21e2530e6067c1d5ba2b9f49c03333ef94367bc Mon Sep 17 00:00:00 2001 From: Marie Date: Mon, 16 Sep 2024 00:35:26 +0200 Subject: [PATCH] fix: don't show quoted toast on cancel of quote note --- packages/frontend/src/components/MkNote.vue | 6 ++++-- packages/frontend/src/components/MkNoteDetailed.vue | 6 ++++-- packages/frontend/src/components/MkNoteSub.vue | 6 ++++-- .../frontend/src/components/MkPostFormDialog.vue | 12 +++++++++--- packages/frontend/src/components/SkNote.vue | 6 ++++-- packages/frontend/src/components/SkNoteDetailed.vue | 6 ++++-- packages/frontend/src/components/SkNoteSub.vue | 6 ++++-- packages/frontend/src/os.ts | 6 +++--- 8 files changed, 36 insertions(+), 18 deletions(-) diff --git a/packages/frontend/src/components/MkNote.vue b/packages/frontend/src/components/MkNote.vue index e2f0a4e492..edae1e91b2 100644 --- a/packages/frontend/src/components/MkNote.vue +++ b/packages/frontend/src/components/MkNote.vue @@ -565,7 +565,8 @@ function quote() { os.post({ renote: appearNote.value, channel: appearNote.value.channel, - }).then(() => { + }).then((cancelled) => { + if (cancelled) return; misskeyApi('notes/renotes', { noteId: appearNote.value.id, userId: $i?.id, @@ -589,7 +590,8 @@ function quote() { } else { os.post({ renote: appearNote.value, - }).then(() => { + }).then((cancelled) => { + if (cancelled) return; misskeyApi('notes/renotes', { noteId: appearNote.value.id, userId: $i?.id, diff --git a/packages/frontend/src/components/MkNoteDetailed.vue b/packages/frontend/src/components/MkNoteDetailed.vue index 64559ef265..123e94c3e0 100644 --- a/packages/frontend/src/components/MkNoteDetailed.vue +++ b/packages/frontend/src/components/MkNoteDetailed.vue @@ -550,7 +550,8 @@ function quote() { os.post({ renote: appearNote.value, channel: appearNote.value.channel, - }).then(() => { + }).then((cancelled) => { + if (cancelled) return; misskeyApi('notes/renotes', { noteId: appearNote.value.id, userId: $i?.id, @@ -574,7 +575,8 @@ function quote() { } else { os.post({ renote: appearNote.value, - }).then(() => { + }).then((cancelled) => { + if (cancelled) return; misskeyApi('notes/renotes', { noteId: appearNote.value.id, userId: $i?.id, diff --git a/packages/frontend/src/components/MkNoteSub.vue b/packages/frontend/src/components/MkNoteSub.vue index 9caed62ce2..45276839ad 100644 --- a/packages/frontend/src/components/MkNoteSub.vue +++ b/packages/frontend/src/components/MkNoteSub.vue @@ -339,7 +339,8 @@ function quote() { os.post({ renote: appearNote.value, channel: appearNote.value.channel, - }).then(() => { + }).then((cancelled) => { + if (cancelled) return; misskeyApi('notes/renotes', { noteId: props.note.id, userId: $i.id, @@ -363,7 +364,8 @@ function quote() { } else { os.post({ renote: appearNote.value, - }).then(() => { + }).then((cancelled) => { + if (cancelled) return; misskeyApi('notes/renotes', { noteId: props.note.id, userId: $i.id, diff --git a/packages/frontend/src/components/MkPostFormDialog.vue b/packages/frontend/src/components/MkPostFormDialog.vue index 947c0ee4d0..cc84c6e0ff 100644 --- a/packages/frontend/src/components/MkPostFormDialog.vue +++ b/packages/frontend/src/components/MkPostFormDialog.vue @@ -5,7 +5,7 @@ SPDX-License-Identifier: AGPL-3.0-only @@ -37,7 +37,7 @@ const props = withDefaults(defineProps<{ }); const emit = defineEmits<{ - (ev: 'closed'): void; + (ev: 'closed', cancelled: boolean): void; }>(); const modal = shallowRef>(); @@ -47,10 +47,16 @@ function onPosted() { modal.value?.close({ useSendAnimation: true, }); + emit('closed', false); +} + +function onCancel() { + modal.value?.close(); + emit('closed', true); } function onModalClosed() { - emit('closed'); + emit('closed', true); } diff --git a/packages/frontend/src/components/SkNote.vue b/packages/frontend/src/components/SkNote.vue index b02d902482..3d5c5f5fae 100644 --- a/packages/frontend/src/components/SkNote.vue +++ b/packages/frontend/src/components/SkNote.vue @@ -565,7 +565,8 @@ function quote() { os.post({ renote: appearNote.value, channel: appearNote.value.channel, - }).then(() => { + }).then((cancelled) => { + if (cancelled) return; misskeyApi('notes/renotes', { noteId: appearNote.value.id, userId: $i?.id, @@ -589,7 +590,8 @@ function quote() { } else { os.post({ renote: appearNote.value, - }).then(() => { + }).then((cancelled) => { + if (cancelled) return; misskeyApi('notes/renotes', { noteId: appearNote.value.id, userId: $i?.id, diff --git a/packages/frontend/src/components/SkNoteDetailed.vue b/packages/frontend/src/components/SkNoteDetailed.vue index cca6c7a40c..5b85e21bac 100644 --- a/packages/frontend/src/components/SkNoteDetailed.vue +++ b/packages/frontend/src/components/SkNoteDetailed.vue @@ -559,7 +559,8 @@ function quote() { os.post({ renote: appearNote.value, channel: appearNote.value.channel, - }).then(() => { + }).then((cancelled) => { + if (cancelled) return; misskeyApi('notes/renotes', { noteId: appearNote.value.id, userId: $i?.id, @@ -583,7 +584,8 @@ function quote() { } else { os.post({ renote: appearNote.value, - }).then(() => { + }).then((cancelled) => { + if (cancelled) return; misskeyApi('notes/renotes', { noteId: appearNote.value.id, userId: $i?.id, diff --git a/packages/frontend/src/components/SkNoteSub.vue b/packages/frontend/src/components/SkNoteSub.vue index c2986b2524..fac35191b9 100644 --- a/packages/frontend/src/components/SkNoteSub.vue +++ b/packages/frontend/src/components/SkNoteSub.vue @@ -353,7 +353,8 @@ function quote() { os.post({ renote: appearNote.value, channel: appearNote.value.channel, - }).then(() => { + }).then((cancelled) => { + if (cancelled) return; misskeyApi('notes/renotes', { noteId: props.note.id, userId: $i.id, @@ -377,7 +378,8 @@ function quote() { } else { os.post({ renote: appearNote.value, - }).then(() => { + }).then((cancelled) => { + if (cancelled) return; misskeyApi('notes/renotes', { noteId: props.note.id, userId: $i.id, diff --git a/packages/frontend/src/os.ts b/packages/frontend/src/os.ts index f6f4d62d50..95a0f06790 100644 --- a/packages/frontend/src/os.ts +++ b/packages/frontend/src/os.ts @@ -691,7 +691,7 @@ export function contextMenu(items: MenuItem[], ev: MouseEvent): Promise { })); } -export function post(props: Record = {}): Promise { +export function post(props: Record = {}): Promise { pleaseLogin(undefined, (props.initialText || props.initialNote ? { type: 'share', params: { @@ -709,8 +709,8 @@ export function post(props: Record = {}): Promise { // 複数のpost formを開いたときに場合によってはエラーになる // もちろん複数のpost formを開けること自体Misskeyサイドのバグなのだが const { dispose } = popup(MkPostFormDialog, props, { - closed: () => { - resolve(); + closed: (cancelled) => { + resolve(cancelled); dispose(); }, });