enhance: クリップのノート数を表示するように (#13686)

* enhance: クリップのノート数を表示できるように

* Update Changelog
This commit is contained in:
かっこかり 2024-04-14 21:30:24 +09:00 committed by GitHub
parent 8c5d9a6295
commit bba3097765
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 99 additions and 33 deletions

View file

@ -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: 'ti ti-plus',