Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix: centralize teleprompter defaults

Richie McIlroy0a14e4ef72a6
diff --git a/apps/desktop/src/routes/teleprompter.tsx b/apps/desktop/src/routes/teleprompter.tsx
index 1eeeb74b7..ce8ad6ce3 100644
--- a/apps/desktop/src/routes/teleprompter.tsx
+++ b/apps/desktop/src/routes/teleprompter.tsx
@@ -15,7 +15,11 @@ import {
import { Toggle } from "~/components/Toggle";
import CaptionControlsMacOS from "~/components/titlebar/controls/CaptionControlsMacOS";
import CaptionControlsWindows11 from "~/components/titlebar/controls/CaptionControlsWindows11";
-import { type TeleprompterStore, teleprompterStore } from "~/store";
+import {
+ type TeleprompterStore,
+ teleprompterDefaults,
+ teleprompterStore,
+} from "~/store";
import { applyMacOSWindowMaterial } from "~/utils/macos-window-material";
import { commands } from "~/utils/tauri";
import { initializeTitlebar } from "~/utils/titlebar-state";
@@ -37,16 +41,6 @@ import {
countWords,
} from "./teleprompter-utils";
-const DEFAULT_STATE: TeleprompterStore = {
- script: "",
- fontSize: 30,
- wordsPerMinute: 150,
- lineHeight: 1.5,
- showCueMarkers: true,
- mirror: false,
- windowOpacityPercent: 92,
-};
-
function ToolButton(props: {
label: string;
active?: boolean;
@@ -99,7 +93,8 @@ export default function Teleprompter() {
const isMacOS = platform === "macos";
const isWindows = platform === "windows";
const isLinux = platform === "linux";
- const [state, setState] = createSignal<TeleprompterStore>(DEFAULT_STATE);
+ const [state, setState] =
+ createSignal<TeleprompterStore>(teleprompterDefaults);
const [isLoaded, setIsLoaded] = createSignal(false);
const [isPlaying, setIsPlaying] = createSignal(false);
const [settingsOpen, setSettingsOpen] = createSignal(false);
@@ -142,7 +137,7 @@ export default function Teleprompter() {
void teleprompterStore
.get()
.then((saved) => {
- if (saved) setState({ ...DEFAULT_STATE, ...saved });
+ if (saved) setState({ ...teleprompterDefaults, ...saved });
setIsLoaded(true);
requestAnimationFrame(resizeEditor);
})
diff --git a/apps/desktop/src/store.ts b/apps/desktop/src/store.ts
index 846ed578a..c7c11444c 100644
--- a/apps/desktop/src/store.ts
+++ b/apps/desktop/src/store.ts
@@ -20,6 +20,16 @@ export type TeleprompterStore = {
windowOpacityPercent: number;
};
+export const teleprompterDefaults: TeleprompterStore = {
+ script: "",
+ fontSize: 30,
+ wordsPerMinute: 150,
+ lineHeight: 1.5,
+ showCueMarkers: true,
+ mirror: false,
+ windowOpacityPercent: 92,
+};
+
export type UserProfileStore = {
userId: string | null;
profile: {
@@ -104,13 +114,5 @@ export const recordingSettingsStore = declareStore<RecordingSettingsStore>(
);
export const teleprompterStore = declareStore<TeleprompterStore>(
"teleprompter",
- {
- script: "",
- fontSize: 30,
- wordsPerMinute: 150,
- lineHeight: 1.5,
- showCueMarkers: true,
- mirror: false,
- windowOpacityPercent: 92,
- },
+ teleprompterDefaults,
);