[bugfix] 1: To do not restore and save the data x,y_pos and its size when the window is minimized.

2: To do not restore and save the message box ratio data when the window is minimized either.
This commit is contained in:
Sakamoto Shiina
2024-11-05 21:26:13 +09:00
parent ef5799cd9b
commit 0f599ce679
3 changed files with 58 additions and 18 deletions

View File

@@ -1,3 +1,4 @@
import { appWindow } from "@tauri-apps/api/window";
import { useStore_MessageInputBoxRatio } from "@store";
import { useStdoutToPython } from "@logics/useStdoutToPython";
import { clampMinMax } from "@utils/clampMinMax";
@@ -9,7 +10,9 @@ export const useMessageInputBoxRatio = () => {
asyncStdoutToPython("/get/data/message_box_ratio");
};
const setMessageInputBoxRatio = (ratio) => {
const asyncSetMessageInputBoxRatio = async (ratio) => {
const minimized = await appWindow.isMinimized();
if (minimized === true) return; // don't save while the window is minimized.
const parsed = parseFloat(ratio.toFixed(2));
const valid_ratio = clampMinMax(parsed, 1, 99);
asyncStdoutToPython("/set/data/message_box_ratio", valid_ratio);
@@ -19,6 +22,6 @@ export const useMessageInputBoxRatio = () => {
currentMessageInputBoxRatio,
getMessageInputBoxRatio,
updateMessageInputBoxRatio,
setMessageInputBoxRatio,
asyncSetMessageInputBoxRatio,
};
};