fix: restore undefined value from null after importing hypaDataV3

This commit is contained in:
Bo26fhmC5M
2025-01-13 19:31:24 +09:00
parent a1158ebdb1
commit 4176a647a5
2 changed files with 8 additions and 6 deletions

View File

@@ -319,15 +319,16 @@
</div> </div>
{/each} {/each}
{/if} {/if}
{:else if $alertStore.type === 'hypaV3'} {:else if $alertStore.type === "hypaV3"}
<div class="fixed inset-0 z-50 bg-black bg-opacity-50 p-4"> <div class="fixed inset-0 z-50 bg-black bg-opacity-50 p-4">
<div class="h-full w-full flex justify-center"> <div class="h-full w-full flex justify-center">
<div class="bg-darkbg p-4 break-any rounded-md flex flex-col w-full max-w-3xl {DBState.db.characters[$selectedCharID].chats[DBState.db.characters[$selectedCharID].chatPage].hypaV3Data.summaries.length === 0 ? 'h-48' : 'max-h-full'}"> <div class="bg-darkbg p-4 break-any rounded-md flex flex-col w-full max-w-3xl {DBState.db.characters[$selectedCharID].chats[DBState.db.characters[$selectedCharID].chatPage].hypaV3Data.summaries.length === 0 ? "h-48" : "max-h-full"}">
<div class="flex justify-between items-center w-full mb-4"> <div class="flex justify-between items-center w-full mb-4">
<h1 class="text-xl font-bold">HypaV3 Data</h1> <h1 class="text-xl font-bold">HypaV3 Data</h1>
<!-- Reset Button -->
<div class="flex items-center gap-2"> <div class="flex items-center gap-2">
<button class="p-2 hover:text-red-500 transition-colors" onclick={async () => { <button class="p-2 hover:text-red-500 transition-colors" onclick={async () => {
const confirmed = await alertConfirm('This action cannot be undone. Do you want to reset HypaV3 data?') const confirmed = await alertConfirm("This action cannot be undone. Do you want to reset HypaV3 data?")
if (confirmed) { if (confirmed) {
DBState.db.characters[$selectedCharID].chats[DBState.db.characters[$selectedCharID].chatPage].hypaV3Data = { DBState.db.characters[$selectedCharID].chats[DBState.db.characters[$selectedCharID].chatPage].hypaV3Data = {
@@ -339,8 +340,8 @@
</button> </button>
<button class="p-2 hover:text-red-500 transition-colors" onclick={() => { <button class="p-2 hover:text-red-500 transition-colors" onclick={() => {
alertStore.set({ alertStore.set({
type: 'none', type: "none",
msg: '' msg: ""
}) })
}}> }}>
<XIcon size={24}/> <XIcon size={24}/>

View File

@@ -60,7 +60,8 @@ function toHypaV3Data(serialData: SerializableHypaV3Data): HypaV3Data {
return { return {
summaries: serialData.summaries.map((summary) => ({ summaries: serialData.summaries.map((summary) => ({
text: summary.text, text: summary.text,
chatMemos: new Set(summary.chatMemos), // Convert null back to undefined (JSON serialization converts undefined to null)
chatMemos: new Set(summary.chatMemos.map(memo => memo === null ? undefined : memo)),
})), })),
}; };
} }