Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

focus app after auth complete

Brendan Allane4c49d35fca8
diff --git a/apps/desktop/src/App.tsx b/apps/desktop/src/App.tsx
index 293ff607f..93312dc60 100644
--- a/apps/desktop/src/App.tsx
+++ b/apps/desktop/src/App.tsx
@@ -11,12 +11,16 @@ const queryClient = new QueryClient();
export default function App() {
return (
<ErrorBoundary
- fallback={(e: Error) => (
- <>
- <p>{e.toString()}</p>
- <p>{e.stack?.toString()}</p>
- </>
- )}
+ fallback={(e: Error) => {
+ console.log("An error was caught by the root error boundary");
+ console.log(e);
+ return (
+ <>
+ <p>{e.toString()}</p>
+ <p>{e.stack?.toString()}</p>
+ </>
+ );
+ }}
>
<QueryClientProvider client={queryClient}>
<Router
diff --git a/apps/desktop/src/routes/(main)/signin.tsx b/apps/desktop/src/routes/(main)/signin.tsx
index 0796810e8..861d63be9 100644
--- a/apps/desktop/src/routes/(main)/signin.tsx
+++ b/apps/desktop/src/routes/(main)/signin.tsx
@@ -6,6 +6,8 @@ import { action, redirect, useAction, useSubmission } from "@solidjs/router";
import callbackTemplate from "./callback.template";
import { authStore } from "../../store";
+import { clientEnv } from "../../utils/env";
+import { getCurrentWindow } from "@tauri-apps/api/window";
const signInAction = action(async () => {
let res: (url: URL) => void;
@@ -28,9 +30,7 @@ const signInAction = action(async () => {
});
await shell.open(
- `${
- import.meta.env.VITE_SERVER_URL
- }/api/desktop/session/request?port=${port}`
+ `${clientEnv.VITE_SERVER_URL}/api/desktop/session/request?port=${port}`
);
const url = await new Promise<URL>((r) => {
@@ -46,6 +46,10 @@ const signInAction = action(async () => {
await authStore.set({ token, expires });
+ getCurrentWindow()
+ .setFocus()
+ .catch(() => {});
+
return redirect("/");
});
diff --git a/apps/desktop/src/utils/env.ts b/apps/desktop/src/utils/env.ts
new file mode 100644
index 000000000..b0aac63b6
--- /dev/null
+++ b/apps/desktop/src/utils/env.ts
@@ -0,0 +1,3 @@
+export const clientEnv = {
+ VITE_SERVER_URL: import.meta.env.VITE_SERVER_URL ?? "https://cap.so",
+};