Allow deleting specific HypaV3 summaries if orphaned

This commit is contained in:
alattalatta
2025-04-22 23:00:59 +09:00
parent 22a50904f8
commit 6837206755
8 changed files with 32 additions and 5 deletions

View File

@@ -404,23 +404,23 @@
summaryUIState.isTranslating = false;
}
function isRerollable(summaryIndex: number): boolean {
function isOrphan(summaryIndex: number): boolean {
const summary = hypaV3DataState.summaries[summaryIndex];
for (const chatMemo of summary.chatMemos) {
if (!getMessageFromChatMemo(chatMemo)) {
return false;
return true;
}
}
return true;
return false;
}
async function toggleReroll(summaryIndex: number): Promise<void> {
const summaryUIState = summaryUIStates[summaryIndex];
if (summaryUIState.isRerolling) return;
if (!isRerollable(summaryIndex)) return;
if (isOrphan(summaryIndex)) return;
summaryUIState.isRerolling = true;
summaryUIState.rerolledText = "Loading...";
@@ -1074,12 +1074,32 @@
<button
class="p-2 text-zinc-400 hover:text-zinc-200 transition-colors"
tabindex="-1"
disabled={!isRerollable(i)}
disabled={isOrphan(i)}
onclick={async () => await toggleReroll(i)}
>
<RefreshCw class="w-4 h-4" />
</button>
<!-- Delete This Button -->
<button
class="p-2 text-zinc-400 hover:text-rose-300 transition-colors"
tabindex="-1"
disabled={!isOrphan(i)}
onclick={async () => {
if (
await alertConfirm(language.hypaV3Modal.deleteThisConfirmMessage)
) {
hypaV3DataState.summaries = hypaV3DataState.summaries.filter(
(_, index) => index !== i
);
}
showHypaV3Alert();
}}
>
<Trash2Icon class="w-4 h-4" />
</button>
<!-- Delete After Button -->
<button
class="p-2 text-zinc-400 hover:text-rose-300 transition-colors"