Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

Refactor picker window hide logic to use signal state

Richie McIlroye1d53e1dda1a
diff --git a/apps/desktop/src/routes/(window-chrome)/new-main/index.tsx b/apps/desktop/src/routes/(window-chrome)/new-main/index.tsx
index 271d340d7..7e92e7e3b 100644
--- a/apps/desktop/src/routes/(window-chrome)/new-main/index.tsx
+++ b/apps/desktop/src/routes/(window-chrome)/new-main/index.tsx
@@ -302,22 +302,24 @@ function Page() {
const isRecording = () => !!currentRecording.data;
const auth = authStore.createQuery();
- let hasHiddenMainWindowForPicker = false;
+ const [hasHiddenMainWindowForPicker, setHasHiddenMainWindowForPicker] =
+ createSignal(false);
createEffect(() => {
const pickerActive = rawOptions.targetMode != null;
- if (pickerActive && !hasHiddenMainWindowForPicker) {
- hasHiddenMainWindowForPicker = true;
+ const hasHidden = hasHiddenMainWindowForPicker();
+ if (pickerActive && !hasHidden) {
+ setHasHiddenMainWindowForPicker(true);
void getCurrentWindow().hide();
- } else if (!pickerActive && hasHiddenMainWindowForPicker) {
- hasHiddenMainWindowForPicker = false;
+ } else if (!pickerActive && hasHidden) {
+ setHasHiddenMainWindowForPicker(false);
const currentWindow = getCurrentWindow();
void currentWindow.show();
void currentWindow.setFocus();
}
});
onCleanup(() => {
- if (!hasHiddenMainWindowForPicker) return;
- hasHiddenMainWindowForPicker = false;
+ if (!hasHiddenMainWindowForPicker()) return;
+ setHasHiddenMainWindowForPicker(false);
void getCurrentWindow().show();
});