diff --git a/src/lib/Others/HypaV3Modal.svelte b/src/lib/Others/HypaV3Modal.svelte index 582236c9..099e669c 100644 --- a/src/lib/Others/HypaV3Modal.svelte +++ b/src/lib/Others/HypaV3Modal.svelte @@ -29,13 +29,16 @@ translation?: string | null; } - const hypaV3DataState = $state( + const hypaV3DataState = $derived( DBState.db.characters[$selectedCharID].chats[ DBState.db.characters[$selectedCharID].chatPage ].hypaV3Data ); - const summaryUIStates = $state( - hypaV3DataState.summaries.map(() => ({ + + let summaryUIStates = $state( + DBState.db.characters[$selectedCharID].chats[ + DBState.db.characters[$selectedCharID].chatPage + ].hypaV3Data.summaries.map(() => ({ isTranslating: false, translation: null, isRerolling: false, @@ -47,8 +50,18 @@ let expandedMessageUIState = $state(null); $effect(() => { - // Detects changes in all nested properties including summaries hypaV3DataState.summaries; + hypaV3DataState.summaries.length; + + summaryUIStates = hypaV3DataState.summaries.map(() => ({ + isTranslating: false, + translation: null, + isRerolling: false, + rerolledText: null, + isRerolledTranslating: false, + rerolledTranslation: null, + })); + expandedMessageUIState = null; }); @@ -354,204 +367,208 @@
{#each hypaV3DataState.summaries as summary, i} -
- -
- Summary #{i + 1} -
- - - - - - - - -
-
- - - - - - {#if summaryUIStates[i].translation} -
- Translation -
- {summaryUIStates[i].translation} -
-
- {/if} - - - {#if summaryUIStates[i].rerolledText} -
-
- Rerolled Summary -
- - - - - - - - -
-
- - - - {#if summaryUIStates[i].rerolledTranslation} -
- Rerolled Translation -
- {summaryUIStates[i].rerolledTranslation} -
-
- {/if} -
- {/if} - - -
+ {#if summaryUIStates[i]} +
+
- - Connected Messages ({summary.chatMemos.length}) - - - -
- - -
- {#each summary.chatMemos as chatMemo} + Summary #{i + 1} +
+ - {/each} + + + + + + +
- - {#if expandedMessageUIState?.summaryIndex === i} - {@const message = getMessageFromChatMemo( - expandedMessageUIState.selectedChatMemo - )} -
- {#if message} - -
- {message.role}'s Message -
- -
- {message.data} -
- {:else} -
Message not found
- {/if} + + - - {#if expandedMessageUIState.translation} + + {#if summaryUIStates[i].translation} +
+ Translation +
+ {summaryUIStates[i].translation} +
+
+ {/if} + + + {#if summaryUIStates[i].rerolledText} +
+
+ Rerolled Summary +
+ + + + + + + + +
+
+ + + + {#if summaryUIStates[i].rerolledTranslation}
TranslationRerolled Translation
- {expandedMessageUIState.translation} + {summaryUIStates[i].rerolledTranslation}
{/if}
{/if} + + +
+
+ + Connected Messages ({summary.chatMemos.length}) + + + +
+ + +
+ {#each summary.chatMemos as chatMemo} + + {/each} +
+ + + {#if expandedMessageUIState?.summaryIndex === i} + {@const message = getMessageFromChatMemo( + expandedMessageUIState.selectedChatMemo + )} +
+ {#if message} + +
+ {message.role}'s Message +
+ +
+ {message.data} +
+ {:else} +
Message not found
+ {/if} + + + {#if expandedMessageUIState.translation} +
+ Translation +
+ {expandedMessageUIState.translation} +
+
+ {/if} +
+ {/if} +
-
+ {/if} {/each} {#if hypaV3DataState.summaries.length === 0}