Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix(desktop): restore saved recorder inputs on mount

Richie McIlroybb21b54a47d9
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 8e0b4965e..282745459 100644
--- a/apps/desktop/src/routes/(window-chrome)/new-main/index.tsx
+++ b/apps/desktop/src/routes/(window-chrome)/new-main/index.tsx
@@ -1836,6 +1836,21 @@ function Page() {
setMicrophoneInitialSettings(null);
});
+ const setMicInput = createMutation(() => ({
+ mutationFn: async (name: string | null) => {
+ const previous = rawOptions.micName ?? null;
+ if (previous !== name) setOptions("micName", name);
+ try {
+ await commands.setMicInput(name);
+ } catch (error) {
+ if (previous !== name) setOptions("micName", previous);
+ throw error;
+ }
+ },
+ }));
+
+ const setCamera = createCameraMutation();
+
createUpdateCheck();
onMount(async () => {
@@ -1867,6 +1882,18 @@ function Page() {
setCanRevealMainWindow(true);
void emit("main-window-ready");
+ if (rawOptions.micName) {
+ setMicInput
+ .mutateAsync(rawOptions.micName)
+ .catch((error) => console.error("Failed to set mic input:", error));
+ }
+
+ if (rawOptions.cameraID) {
+ setCamera
+ .mutateAsync({ model: rawOptions.cameraID })
+ .catch((error) => console.error("Failed to set camera input:", error));
+ }
+
const unlistenFocus = currentWindow.onFocusChanged(
({ payload: focused }) => {
if (focused) {
@@ -2083,21 +2110,6 @@ function Page() {
}
});
- const setMicInput = createMutation(() => ({
- mutationFn: async (name: string | null) => {
- const previous = rawOptions.micName ?? null;
- if (previous !== name) setOptions("micName", name);
- try {
- await commands.setMicInput(name);
- } catch (error) {
- if (previous !== name) setOptions("micName", previous);
- throw error;
- }
- },
- }));
-
- const setCamera = createCameraMutation();
-
const license = createLicenseQuery();
const signIn = createSignInMutation();