From 01c19e4f5599ff72e495632c35b32380c2da850e Mon Sep 17 00:00:00 2001 From: thatonecalculator Date: Thu, 1 Dec 2022 23:11:11 -0800 Subject: [PATCH] Renote confirmation (closes #9051 & #9166) --- CALCKEY.md | 1 + .../client/src/components/MkRenoteButton.vue | 59 ++++++++++++------- 2 files changed, 38 insertions(+), 22 deletions(-) diff --git a/CALCKEY.md b/CALCKEY.md index 892c79607..dfcb191e4 100644 --- a/CALCKEY.md +++ b/CALCKEY.md @@ -89,6 +89,7 @@ - Patron list - Animations respect reduced motion - Obliteration of Ai-chan +- Undo renote button inside original note - MissV: [fix Misskey Forkbomb](https://code.vtopia.live/Vtopia/MissV/commit/40b23c070bd4adbb3188c73546c6c625138fb3c1) - [Make showing ads optional](https://github.com/misskey-dev/misskey/pull/8996) - [Tapping avatar in mobile opens account modal](https://github.com/misskey-dev/misskey/pull/9056) diff --git a/packages/client/src/components/MkRenoteButton.vue b/packages/client/src/components/MkRenoteButton.vue index c3cc5794e..7550c4ab0 100644 --- a/packages/client/src/components/MkRenoteButton.vue +++ b/packages/client/src/components/MkRenoteButton.vue @@ -55,29 +55,45 @@ useTooltip(buttonRef, async (showing) => { const renote = (viaKeyboard = false, ev?: MouseEvent) => { pleaseLogin(); - if (defaultStore.state.seperateRenoteQuote) { - os.api('notes/create', { - renoteId: props.note.id, - visibility: props.note.visibility, - }); - const el = ev && (ev.currentTarget ?? ev.target) as HTMLElement | null | undefined; - if (el) { - const rect = el.getBoundingClientRect(); - const x = rect.left + (el.offsetWidth / 2); - const y = rect.top + (el.offsetHeight / 2); - os.popup(Ripple, { x, y }, {}, 'end'); - } - } else { - os.popupMenu([{ - text: i18n.ts.renote, - icon: 'ph-repeat-bold ph-lg', + let buttonActions = [{ + text: i18n.ts.renote, + icon: 'ph-repeat-bold ph-lg', + action: () => { + os.api('notes/create', { + renoteId: props.note.id, + visibility: props.note.visibility, + }); + const el = ev && (ev.currentTarget ?? ev.target) as HTMLElement | null | undefined; + if (el) { + const rect = el.getBoundingClientRect(); + const x = rect.left + (el.offsetWidth / 2); + const y = rect.top + (el.offsetHeight / 2); + os.popup(Ripple, { x, y }, {}, 'end'); + } + }, + }]; + let users; + os.api('notes/renotes', { + noteId: props.note.id, + limit: 11, + }).then((renotes) => { + users = renotes.map(x => x.user); + }); + const hasRenotedBefore = users.includes($i); + + if (hasRenotedBefore) { + buttonActions.push({ + text: i18n.ts.unrenote, + icon: 'ph-eraser-bold ph-lg', action: () => { - os.api('notes/create', { - renoteId: props.note.id, - visibility: props.note.visibility, + os.api('notes/unrenote', { + noteId: props.note.id, }); }, - }, { + }); + } + if (!defaultStore.state.seperateRenoteQuote) { + buttonActions.push({ text: i18n.ts.quote, icon: 'ph-quotes-bold ph-lg', action: () => { @@ -85,10 +101,9 @@ const renote = (viaKeyboard = false, ev?: MouseEvent) => { renote: props.note, }); }, - }], buttonRef.value, { - viaKeyboard, }); } + os.popupMenu(buttonActions, buttonRef.value, { viaKeyboard }); };