Skip to content

Commit 06747be

Browse files
authored
remove sign in window (#434)
* remove sign in window inlines sign in into Start Recording button in (main) and Sign In in settings * fix recordings overlay + remove export force option * remove sign in page
1 parent 480fc9a commit 06747be

File tree

11 files changed

+131
-134
lines changed

11 files changed

+131
-134
lines changed

apps/desktop/src-tauri/src/export.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ pub async fn export_video(
1010
app: AppHandle,
1111
path: PathBuf,
1212
progress: tauri::ipc::Channel<RenderProgress>,
13-
force: bool,
1413
fps: u32,
1514
resolution_base: XY<u32>,
1615
) -> Result<PathBuf, String> {
@@ -39,11 +38,6 @@ pub async fn export_video(
3938

4039
let output_path = editor_instance.meta().output_path();
4140

42-
// If the file exists and we're not forcing a re-render, return it
43-
if output_path.exists() && !force {
44-
return Ok(output_path);
45-
}
46-
4741
progress
4842
.send(RenderProgress::EstimatedTotalFrames { total_frames })
4943
.ok();

apps/desktop/src-tauri/src/recording.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,6 @@ pub async fn start_recording(
212212
// Allow the recording to proceed without error for any signed-in user
213213
_ => {
214214
// User is not signed in
215-
let _ = ShowCapWindow::SignIn.show(&app).await;
216215
return Err("Please sign in to use instant recording".to_string());
217216
}
218217
}

apps/desktop/src-tauri/src/windows.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ pub enum CapWindowId {
3636
Camera,
3737
InProgressRecording,
3838
Upgrade,
39-
SignIn,
4039
ModeSelect,
4140
}
4241

@@ -53,7 +52,6 @@ impl FromStr for CapWindowId {
5352
"in-progress-recording" => Self::InProgressRecording,
5453
"recordings-overlay" => Self::RecordingsOverlay,
5554
"upgrade" => Self::Upgrade,
56-
"signin" => Self::SignIn,
5755
"mode-select" => Self::ModeSelect,
5856
s if s.starts_with("editor-") => Self::Editor {
5957
id: s
@@ -86,7 +84,6 @@ impl std::fmt::Display for CapWindowId {
8684
Self::InProgressRecording => write!(f, "in-progress-recording"),
8785
Self::RecordingsOverlay => write!(f, "recordings-overlay"),
8886
Self::Upgrade => write!(f, "upgrade"),
89-
Self::SignIn => write!(f, "signin"),
9087
Self::ModeSelect => write!(f, "mode-select"),
9188
Self::Editor { id } => write!(f, "editor-{id}"),
9289
}
@@ -106,7 +103,6 @@ impl CapWindowId {
106103
Self::CaptureArea => "Cap Capture Area".to_string(),
107104
Self::InProgressRecording => "Cap In Progress Recording".to_string(),
108105
Self::Editor { .. } => "Cap Editor".to_string(),
109-
Self::SignIn => "Cap Sign In".to_string(),
110106
Self::ModeSelect => "Cap Mode Selection".to_string(),
111107
Self::Camera => "Cap Camera".to_string(),
112108
Self::RecordingsOverlay => "Cap Recordings Overlay".to_string(),
@@ -122,7 +118,6 @@ impl CapWindowId {
122118
| Self::Editor { .. }
123119
| Self::Settings
124120
| Self::Upgrade
125-
| Self::SignIn
126121
| Self::ModeSelect
127122
)
128123
}
@@ -149,7 +144,6 @@ impl CapWindowId {
149144
Some(match self {
150145
Self::Setup => (600.0, 600.0),
151146
Self::Main => (300.0, 360.0),
152-
Self::SignIn => (300.0, 360.0),
153147
Self::Editor { .. } => (1275.0, 800.0),
154148
Self::Settings => (600.0, 450.0),
155149
Self::Camera => (460.0, 920.0),
@@ -172,7 +166,6 @@ pub enum ShowCapWindow {
172166
Camera { ws_port: u16 },
173167
InProgressRecording { position: Option<(f64, f64)> },
174168
Upgrade,
175-
SignIn,
176169
ModeSelect,
177170
}
178171

@@ -239,13 +232,6 @@ impl ShowCapWindow {
239232
Box::pin(Self::Setup.show(app)).await?
240233
}
241234
}
242-
Self::SignIn => self
243-
.window_builder(app, "/signin")
244-
.resizable(false)
245-
.maximized(false)
246-
.maximizable(false)
247-
.center()
248-
.build()?,
249235
Self::Settings { page } => self
250236
.window_builder(
251237
app,
@@ -568,7 +554,6 @@ impl ShowCapWindow {
568554
ShowCapWindow::Camera { .. } => CapWindowId::Camera,
569555
ShowCapWindow::InProgressRecording { .. } => CapWindowId::InProgressRecording,
570556
ShowCapWindow::Upgrade => CapWindowId::Upgrade,
571-
ShowCapWindow::SignIn => CapWindowId::SignIn,
572557
ShowCapWindow::ModeSelect => CapWindowId::ModeSelect,
573558
}
574559
}

apps/desktop/src/routes/(window-chrome)/signin.tsx renamed to apps/desktop/src/components/SignInButton.tsx

Lines changed: 21 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,11 @@ import { clientEnv } from "~/utils/env";
1212
import { getCurrentWindow } from "@tauri-apps/api/window";
1313
import { commands } from "~/utils/tauri";
1414
import { identifyUser, trackEvent } from "~/utils/analytics";
15+
import { ComponentProps } from "solid-js";
1516

16-
export default function Page() {
17+
export function SignInButton(
18+
props: Omit<ComponentProps<typeof Button>, "onClick">
19+
) {
1720
const signIn = createMutation(() => ({
1821
mutationFn: async (abort: AbortController) => {
1922
const platform = import.meta.env.DEV ? "web" : "desktop";
@@ -28,45 +31,27 @@ export default function Page() {
2831

2932
await processAuthData(await session.complete());
3033

31-
await commands.showWindow("Main");
32-
33-
// Add a small delay to ensure window is ready
34-
await new Promise((resolve) => setTimeout(resolve, 500));
35-
36-
const mainWindow = await Window.getByLabel("main");
37-
mainWindow?.setFocus();
38-
39-
getCurrentWindow().close();
34+
getCurrentWindow().setFocus();
4035
},
4136
}));
4237

4338
return (
44-
<div class="flex flex-col p-[1rem] gap-[0.75rem] text-[0.875rem] font-[400] flex-1 bg-gray-100">
45-
<div class="space-y-[0.375rem] flex-1">
46-
<IconCapLogo class="size-[3rem]" />
47-
<h1 class="text-[1rem] font-[700] text-black-transparent-80">
48-
Sign in to Cap
49-
</h1>
50-
<p class="text-gray-400">Beautiful screen recordings, owned by you.</p>
51-
</div>
52-
{signIn.isPending ? (
53-
<Button
54-
variant="secondary"
55-
onClick={() => {
56-
signIn.variables.abort();
57-
signIn.reset();
58-
}}
59-
>
60-
Cancel sign in
61-
</Button>
62-
) : (
63-
<div class="flex flex-col gap-2">
64-
<Button onClick={() => signIn.mutate(new AbortController())}>
65-
Sign in with your browser
66-
</Button>
67-
</div>
68-
)}
69-
</div>
39+
<Button
40+
size="md"
41+
class="flex flex-grow justify-center items-center"
42+
{...props}
43+
variant={signIn.isPending ? "secondary" : props.variant}
44+
onClick={() => {
45+
if (signIn.isPending) {
46+
signIn.variables.abort();
47+
signIn.reset();
48+
} else {
49+
signIn.mutate(new AbortController());
50+
}
51+
}}
52+
>
53+
{signIn.isPending ? "Cancel Sign In" : props.children ?? "Sign In"}
54+
</Button>
7055
);
7156
}
7257

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
export default `
2+
<!DOCTYPE html>
3+
<html lang="en">
4+
<head>
5+
<meta charset="UTF-8">
6+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
7+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
8+
<meta http-equiv="Cache-Control" content="no-store, no-cache, must-revalidate">
9+
<meta http-equiv="Pragma" content="no-cache">
10+
<title>Cap Auth</title>
11+
<style>
12+
html, body {
13+
width: 100%;
14+
height: 100%;
15+
margin: 0;
16+
padding: 0;
17+
font-weight: 400;
18+
}
19+
body {
20+
display: flex;
21+
align-items: center;
22+
justify-content: center;
23+
font-family: sans-serif;
24+
text-align: center;
25+
background-color: #f8f9fa;
26+
}
27+
.container {
28+
padding: 30px;
29+
width: 100%;
30+
max-width: 400px;
31+
margin: 0 auto;
32+
}
33+
.logo {
34+
width: 130px;
35+
height: auto;
36+
margin-bottom: 20px;
37+
}
38+
p {
39+
font-size: 21px;
40+
line-height: 26px;
41+
color: #12161F;
42+
margin: 0;
43+
}
44+
.error {
45+
color: #dc2626;
46+
margin-top: 12px;
47+
font-size: 16px;
48+
}
49+
</style>
50+
</head>
51+
<body>
52+
<div class="container">
53+
<svg class="logo" viewBox="0 0 103 40" fill="none" xmlns="http://www.w3.org/2000/svg"> <rect x="0.25" y="0.25" width="39.5" height="39.5" rx="7.75" fill="white"/> <rect x="0.25" y="0.25" width="39.5" height="39.5" rx="7.75" stroke="#E7EAF0" stroke-width="0.5"/> <path d="M20 36C28.8365 36 36 28.8365 36 20C36 11.1635 28.8365 4 20 4C11.1635 4 4 11.1635 4 20C4 28.8365 11.1635 36 20 36Z" fill="#4785FF"/> <path d="M20.0001 33C27.1797 33 33 27.1797 33 20.0001C33 12.8203 27.1797 7 20.0001 7C12.8203 7 7 12.8204 7 20.0001C7 27.1797 12.8204 33 20.0001 33Z" fill="#ADC9FF"/> <path d="M20.0001 30.0002C25.5229 30.0002 30.0002 25.5229 30.0002 20.0001C30.0002 14.4773 25.5229 10.0002 20.0001 10.0002C14.4773 10.0002 10.0002 14.4773 10.0002 20.0001C10.0002 25.5229 14.4773 30.0002 20.0001 30.0002Z" fill="white"/> <path d="M58.416 30.448C53.012 30.448 49.204 26.584 49.204 20.088C49.204 13.704 52.872 9.672 58.472 9.672C63.54 9.672 66.256 12.332 67.096 16.84L63.288 17.036C62.812 14.432 61.216 12.836 58.472 12.836C55.084 12.836 52.984 15.664 52.984 20.088C52.984 24.568 55.14 27.284 58.444 27.284C61.384 27.284 62.952 25.576 63.4 22.72L67.208 22.916C66.424 27.592 63.456 30.448 58.416 30.448ZM74.6451 30.336C71.5091 30.336 69.4371 28.852 69.4371 26.248C69.4371 23.672 71.0331 22.3 74.3091 21.656L79.2651 20.676C79.2651 18.576 78.2851 17.484 76.4091 17.484C74.6451 17.484 73.6931 18.296 73.3571 19.808L69.6891 19.64C70.2771 16.504 72.6851 14.712 76.4091 14.712C80.6651 14.712 82.8491 16.952 82.8491 20.928V26.36C82.8491 27.172 83.1291 27.396 83.6891 27.396H84.1651V30C83.9411 30.056 83.3531 30.112 82.8771 30.112C81.2531 30.112 80.0491 29.524 79.7411 27.676C79.0131 29.272 77.1091 30.336 74.6451 30.336ZM75.3731 27.732C77.7531 27.732 79.2651 26.22 79.2651 23.952V23.112L75.4011 23.896C73.8051 24.204 73.1611 24.876 73.1611 25.912C73.1611 27.088 73.9451 27.732 75.3731 27.732ZM86.8741 34.2V15.048H90.3181L90.3741 17.26C91.2421 15.608 92.8941 14.712 94.8541 14.712C99.1101 14.712 101.21 18.212 101.21 22.524C101.21 26.836 99.0821 30.336 94.8261 30.336C92.9221 30.336 91.2701 29.412 90.4581 27.956V34.2H86.8741ZM93.9861 27.424C96.1701 27.424 97.4861 25.604 97.4861 22.524C97.4861 19.444 96.1701 17.624 93.9861 17.624C91.8021 17.624 90.4581 19.276 90.4581 22.524C90.4581 25.772 91.7741 27.424 93.9861 27.424Z" fill="#12161F"/> </svg>
54+
<p id="message">You are now signed in. Please re-open the Cap desktop app to continue.</p>
55+
<div id="error-container"></div>
56+
</div>
57+
</body>
58+
</html>
59+
`;

apps/desktop/src/routes/(window-chrome)/(main).tsx

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -293,26 +293,34 @@ export default function () {
293293
<SystemAudio options={options.data} setOptions={setOptions} />
294294
)}
295295
<div class="flex items-center space-x-1 w-full">
296-
<Button
297-
disabled={toggleRecording.isPending}
298-
variant={isRecording() ? "destructive" : "primary"}
299-
size="md"
300-
onClick={() => toggleRecording.mutate()}
301-
class="flex flex-grow justify-center items-center"
302-
>
303-
{isRecording() ? (
304-
"Stop Recording"
305-
) : (
306-
<>
307-
{options.data?.mode === "instant" ? (
308-
<IconCapInstant class="w-[0.8rem] h-[0.8rem] mr-1.5" />
309-
) : (
310-
<IconCapFilmCut class="w-[0.8rem] h-[0.8rem] mr-2 -mt-[1.5px]" />
311-
)}
312-
Start Recording
313-
</>
314-
)}
315-
</Button>
296+
{options.data?.mode === "instant" && !auth.data ? (
297+
<SignInButton>
298+
Sign In for{" "}
299+
<IconCapInstant class="size-[0.8rem] ml-[0.14rem] mr-0.5" />
300+
Instant Mode
301+
</SignInButton>
302+
) : (
303+
<Button
304+
disabled={toggleRecording.isPending}
305+
variant={isRecording() ? "destructive" : "primary"}
306+
size="md"
307+
onClick={() => toggleRecording.mutate()}
308+
class="flex flex-grow justify-center items-center"
309+
>
310+
{isRecording() ? (
311+
"Stop Recording"
312+
) : (
313+
<>
314+
{options.data?.mode === "instant" ? (
315+
<IconCapInstant class="size-[0.8rem] mr-1.5" />
316+
) : (
317+
<IconCapFilmCut class="size-[0.8rem] mr-2 -mt-[1.5px]" />
318+
)}
319+
Start Recording
320+
</>
321+
)}
322+
</Button>
323+
)}
316324
{/* <Button
317325
disabled={isRecording()}
318326
variant="secondary"
@@ -362,6 +370,7 @@ import { Transition } from "solid-transition-group";
362370
import { apiClient } from "~/utils/web-api";
363371
import { useWindowChrome } from "./Context";
364372
import { authStore, generalSettingsStore } from "~/store";
373+
import { SignInButton } from "~/components/SignInButton";
365374

366375
let hasChecked = false;
367376
function createUpdateCheck() {

apps/desktop/src/routes/(window-chrome)/settings.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { getVersion } from "@tauri-apps/api/app";
44
import "@total-typescript/ts-reset/filter-boolean";
55
import { createResource, For, Show, Suspense } from "solid-js";
66
import toast from "solid-toast";
7+
import { SignInButton } from "~/components/SignInButton";
78

89
import { authStore } from "~/store";
910
import { trackEvent } from "~/utils/analytics";
@@ -23,8 +24,6 @@ export default function Settings(props: RouteSectionProps) {
2324
if (auth.data) {
2425
trackEvent("user_signed_out", { platform: "desktop" });
2526
authStore.set(undefined);
26-
} else {
27-
commands.showWindow("SignIn");
2827
}
2928
};
3029

@@ -136,13 +135,17 @@ export default function Settings(props: RouteSectionProps) {
136135
)}
137136
</For>
138137
</ul>
139-
<div class="p-[0.625rem]">
138+
<div class="p-[0.625rem] text-left flex flex-col">
140139
<Show when={version()}>
141140
{(v) => <p class="mb-1 text-xs text-gray-400">v{v()}</p>}
142141
</Show>
143-
<Button onClick={handleAuth} variant="secondary" class="w-full">
144-
{auth.data ? "Sign Out" : "Sign In"}
145-
</Button>
142+
{auth.data ? (
143+
<Button onClick={handleAuth} variant="secondary" class="w-full">
144+
Sign Out
145+
</Button>
146+
) : (
147+
<SignInButton>Sign In</SignInButton>
148+
)}
146149
</div>
147150
</div>
148151
<div class="overflow-y-hidden flex-1 bg-gray-50 animate-in">

apps/desktop/src/routes/editor/ExportDialog.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ const ExportDialog = () => {
151151
const outputPath = await commands.exportVideo(
152152
path,
153153
progress,
154-
true,
155154
settings.fps,
156155
{
157156
x: settings.resolution.width,
@@ -238,7 +237,6 @@ const ExportDialog = () => {
238237
const videoPath = await commands.exportVideo(
239238
path,
240239
progress,
241-
true,
242240
settings.fps,
243241
{
244242
x: settings.resolution.width,
@@ -285,7 +283,6 @@ const ExportDialog = () => {
285283
// Check authentication first
286284
const existingAuth = await authStore.get();
287285
if (!existingAuth) {
288-
await commands.showWindow("SignIn");
289286
throw new Error("You need to sign in to share recordings");
290287
}
291288

@@ -360,7 +357,7 @@ const ExportDialog = () => {
360357
);
361358
};
362359

363-
await commands.exportVideo(path, progress, true, settings.fps, {
360+
await commands.exportVideo(path, progress, settings.fps, {
364361
x: settings.resolution.width,
365362
y: settings.resolution.height,
366363
});
@@ -375,7 +372,6 @@ const ExportDialog = () => {
375372
});
376373

377374
if (result === "NotAuthenticated") {
378-
await commands.showWindow("SignIn");
379375
throw new Error("You need to sign in to share recordings");
380376
} else if (result === "PlanCheckFailed")
381377
throw new Error("Failed to verify your subscription status");

0 commit comments

Comments
 (0)