diff options
Diffstat (limited to 'packages/frontend/src/scripts/get-note-menu.ts')
| -rw-r--r-- | packages/frontend/src/scripts/get-note-menu.ts | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/packages/frontend/src/scripts/get-note-menu.ts b/packages/frontend/src/scripts/get-note-menu.ts index 40359a88bb..bbe1a52f8f 100644 --- a/packages/frontend/src/scripts/get-note-menu.ts +++ b/packages/frontend/src/scripts/get-note-menu.ts @@ -26,6 +26,14 @@ export async function getNoteClipMenu(props: { isDeleted: Ref<boolean>; currentClip?: Misskey.entities.Clip; }) { + function getClipName(clip: Misskey.entities.Clip) { + if ($i && clip.userId === $i.id && clip.notesCount != null) { + return `${clip.name} (${clip.notesCount}/${$i.policies.noteEachClipsLimit})`; + } else { + return clip.name; + } + } + const isRenote = ( props.note.renote != null && props.note.text == null && @@ -37,7 +45,7 @@ export async function getNoteClipMenu(props: { const clips = await clipsCache.fetch(); const menu: MenuItem[] = [...clips.map(clip => ({ - text: clip.name, + text: getClipName(clip), action: () => { claimAchievement('noteClipped1'); os.promiseDialog( @@ -50,7 +58,18 @@ export async function getNoteClipMenu(props: { text: i18n.tsx.confirmToUnclipAlreadyClippedNote({ name: clip.name }), }); if (!confirm.canceled) { - os.apiWithDialog('clips/remove-note', { clipId: clip.id, noteId: appearNote.id }); + os.apiWithDialog('clips/remove-note', { clipId: clip.id, noteId: appearNote.id }).then(() => { + clipsCache.set(clips.map(c => { + if (c.id === clip.id) { + return { + ...c, + notesCount: Math.max(0, ((c.notesCount ?? 0) - 1)), + }; + } else { + return c; + } + })); + }); if (props.currentClip?.id === clip.id) props.isDeleted.value = true; } } else { @@ -60,7 +79,18 @@ export async function getNoteClipMenu(props: { }); } }, - ); + ).then(() => { + clipsCache.set(clips.map(c => { + if (c.id === clip.id) { + return { + ...c, + notesCount: (c.notesCount ?? 0) + 1, + }; + } else { + return c; + } + })); + }); }, })), { type: 'divider' }, { icon: 'ph-plus ph-bold ph-lg', |