Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

clippy bits

Richie McIlroy877c0d5252a7
diff --git a/apps/desktop/src/routes/editor/ConfigSidebar.tsx b/apps/desktop/src/routes/editor/ConfigSidebar.tsx
index 3cbfb0102..4344bc09c 100644
--- a/apps/desktop/src/routes/editor/ConfigSidebar.tsx
+++ b/apps/desktop/src/routes/editor/ConfigSidebar.tsx
@@ -412,8 +412,7 @@ export function ConfigSidebar() {
{
id: TAB_IDS.cursor,
icon: IconCapCursor,
- disabled:
- meta().type !== "multiple" || !meta().segments[0]?.cursor,
+ disabled: !meta().hasRecordedCursorData,
},
{
id: TAB_IDS.keyboard,
@@ -1244,9 +1243,7 @@ export function ConfigSidebar() {
index: idx,
}))
.filter(
- (
- s,
- ): s is { segment: SceneSegment; index: number } =>
+ (s): s is { segment: SceneSegment; index: number } =>
s.segment !== undefined,
);
@@ -1319,9 +1316,7 @@ export function ConfigSidebar() {
index: idx,
}))
.filter(
- (
- s,
- ): s is { segment: TimelineSegment; index: number } =>
+ (s): s is { segment: TimelineSegment; index: number } =>
s.segment !== undefined,
);
@@ -1412,13 +1407,14 @@ function BackgroundConfig(props: { scrollRef: HTMLDivElement }) {
// Load initial batch
const initialPaths = await Promise.all(visibleWallpaperPaths);
- return initialPaths
- .filter((p): p is { id: string; path: string } => p.path !== null)
- .map(({ id, path }) => ({
+ return initialPaths.flatMap(({ id, path }) => {
+ if (path === null) return [];
+ return {
id,
url: convertFileSrc(path),
rawPath: path,
- }));
+ };
+ });
});
// set padding if background is selected
diff --git a/apps/web/__tests__/unit/developer-cron-storage.test.ts b/apps/web/__tests__/unit/developer-cron-storage.test.ts
index 71449c265..38db71ce4 100644
--- a/apps/web/__tests__/unit/developer-cron-storage.test.ts
+++ b/apps/web/__tests__/unit/developer-cron-storage.test.ts
@@ -5,8 +5,8 @@ const mockDb = vi.fn();
type DbRow = Record<string, unknown>;
type JsonBody = Record<string, unknown>;
type TransactionValues = {
- type?: string;
- amountMicroCredits?: number;
+ type: string;
+ amountMicroCredits: number;
};
type MockDbChain = {
select: ReturnType<typeof vi.fn>;
@@ -136,7 +136,19 @@ function setupDbSequence(
}
function isTransactionValues(value: unknown): value is TransactionValues {
- return typeof value === "object" && value !== null;
+ return (
+ typeof value === "object" &&
+ value !== null &&
+ "type" in value &&
+ typeof value.type === "string" &&
+ "amountMicroCredits" in value &&
+ typeof value.amountMicroCredits === "number"
+ );
+}
+
+function getCapturedJsonBody() {
+ if (capturedJsonBody === null) throw new Error("Expected JSON response body");
+ return capturedJsonBody;
}
beforeEach(() => {
@@ -199,7 +211,7 @@ describe("developer-storage cron job", () => {
success: true,
appsProcessed: 1,
});
- expect(capturedJsonBody.date).toMatch(/^\d{4}-\d{2}-\d{2}$/);
+ expect(getCapturedJsonBody().date).toMatch(/^\d{4}-\d{2}-\d{2}$/);
});
it("skips already-processed apps", async () => {
@@ -257,7 +269,7 @@ describe("developer-storage cron job", () => {
describe("transaction behavior", () => {
it("creates negative transaction for storage_daily", async () => {
const GET = await importGET();
- let insertValues: TransactionValues | null = null;
+ let insertValues: unknown = null;
setupDbSequence(
[
@@ -281,7 +293,8 @@ describe("developer-storage cron job", () => {
await GET(makeRequest(`Bearer ${CRON_SECRET}`));
- expect(insertValues).not.toBeNull();
+ if (!isTransactionValues(insertValues))
+ throw new Error("Expected storage transaction");
expect(insertValues.type).toBe("storage_daily");
expect(insertValues.amountMicroCredits).toBe(-33);
});
@@ -324,11 +337,12 @@ describe("developer-storage cron job", () => {
await GET(makeRequest(`Bearer ${CRON_SECRET}`));
- expect(capturedJsonBody).toHaveProperty("success", true);
- expect(capturedJsonBody).toHaveProperty("date");
- expect(capturedJsonBody).toHaveProperty("appsProcessed");
- expect(capturedJsonBody.date).toMatch(/^\d{4}-\d{2}-\d{2}$/);
- expect(typeof capturedJsonBody.appsProcessed).toBe("number");
+ const body = getCapturedJsonBody();
+ expect(body).toHaveProperty("success", true);
+ expect(body).toHaveProperty("date");
+ expect(body).toHaveProperty("appsProcessed");
+ expect(body.date).toMatch(/^\d{4}-\d{2}-\d{2}$/);
+ expect(typeof body.appsProcessed).toBe("number");
});
});
diff --git a/apps/web/app/(site)/(seo)/open-source-screen-recorder/page.tsx b/apps/web/app/(site)/(seo)/open-source-screen-recorder/page.tsx
index 607dbc2b5..7d5367376 100644
--- a/apps/web/app/(site)/(seo)/open-source-screen-recorder/page.tsx
+++ b/apps/web/app/(site)/(seo)/open-source-screen-recorder/page.tsx
@@ -42,9 +42,7 @@ export default function Page() {
return (
<>
<script type="application/ld+json">
- {JSON.stringify(
- createFAQSchema(openSourceScreenRecorderContent.faqs),
- )}
+ {JSON.stringify(createFAQSchema(openSourceScreenRecorderContent.faqs))}
</script>
<OpenSourceScreenRecorderPage />
</>
diff --git a/apps/web/app/(site)/(seo)/self-hosted-screen-recording/page.tsx b/apps/web/app/(site)/(seo)/self-hosted-screen-recording/page.tsx
index cbc6cf621..95dfe3db3 100644
--- a/apps/web/app/(site)/(seo)/self-hosted-screen-recording/page.tsx
+++ b/apps/web/app/(site)/(seo)/self-hosted-screen-recording/page.tsx
@@ -45,9 +45,7 @@ export default function Page() {
return (
<>
<script type="application/ld+json">
- {JSON.stringify(
- createFAQSchema(selfHostedScreenRecordingContent.faqs),
- )}
+ {JSON.stringify(createFAQSchema(selfHostedScreenRecordingContent.faqs))}
</script>
<SelfHostedScreenRecordingPage />
</>
diff --git a/crates/editor/src/playback.rs b/crates/editor/src/playback.rs
index 4eaaca29e..93feb4037 100644
--- a/crates/editor/src/playback.rs
+++ b/crates/editor/src/playback.rs
@@ -1384,7 +1384,9 @@ impl AudioPlayback {
let mut config = supported_config.config();
config.channels = output_info.channels as u16;
+ #[cfg(not(target_os = "windows"))]
let sample_rate = output_info.sample_rate;
+ #[cfg(not(target_os = "windows"))]
let buffer_size = output_info.buffer_size;
let playhead = f64::from(start_frame_number) / f64::from(fps);
@@ -1392,7 +1394,7 @@ impl AudioPlayback {
info!(
duration_secs = duration_secs,
start_playhead = playhead,
- sample_rate = sample_rate,
+ sample_rate = output_info.sample_rate,
"Creating pre-rendered audio stream"
);
diff --git a/packages/web-backend/src/Auth.ts b/packages/web-backend/src/Auth.ts
index f03f09fd7..aec0188ae 100644
--- a/packages/web-backend/src/Auth.ts
+++ b/packages/web-backend/src/Auth.ts
@@ -4,6 +4,7 @@ import {
CurrentUser,
type DatabaseError,
HttpAuthMiddleware,
+ UserId,
} from "@cap/web-domain";
import { HttpApiError, HttpServerRequest } from "@effect/platform";
import * as Dz from "drizzle-orm";
@@ -23,7 +24,12 @@ export const getCurrentUser = Effect.gen(function* () {
db
.select()
.from(Db.users)
- .where(Dz.eq(Db.users.id, (session.user as { id: string }).id)),
+ .where(
+ Dz.eq(
+ Db.users.id,
+ UserId.make((session.user as { id: string }).id),
+ ),
+ ),
);
return Option.fromNullable(currentUser);