From 682f536c5a39aa53eaef76a7277e131fc0b105d9 Mon Sep 17 00:00:00 2001 From: Bo26fhmC5M <88071760+Bo26fhmC5M@users.noreply.github.com> Date: Thu, 16 Jan 2025 01:36:29 +0900 Subject: [PATCH] refactor: extract double confirmation logic into reusable function --- src/lib/Others/HypaV3Modal.svelte | 44 ++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/src/lib/Others/HypaV3Modal.svelte b/src/lib/Others/HypaV3Modal.svelte index 099e669c..690b8e61 100644 --- a/src/lib/Others/HypaV3Modal.svelte +++ b/src/lib/Others/HypaV3Modal.svelte @@ -8,7 +8,7 @@ CheckIcon, } from "lucide-svelte"; import TextAreaInput from "../UI/GUI/TextAreaInput.svelte"; - import { alertConfirm } from "../../ts/alert"; + import { alertConfirm, showHypaV3Alert } from "../../ts/alert"; import { DBState, alertStore, selectedCharID } from "src/ts/stores.svelte"; import { summarize } from "src/ts/process/memory/hypav3"; import { translateHTML } from "src/ts/translator/translator"; @@ -65,6 +65,21 @@ expandedMessageUIState = null; }); + async function confirmTwice( + firstMessage: string, + secondMessage: string + ): Promise { + let confirmed = await alertConfirm(firstMessage); + + if (confirmed) { + confirmed = await alertConfirm(secondMessage); + + if (confirmed) { + return true; + } + } + } + function getMessageFromChatMemo( chatMemo: string | null ): { role: string; data: string } | null { @@ -327,22 +342,19 @@