Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
feat(desktop): reorganize general settings for Cap Pro and server URL
Richie McIlroy99ec20770172
diff --git a/apps/desktop/src/routes/(window-chrome)/settings/general.tsx b/apps/desktop/src/routes/(window-chrome)/settings/general.tsxindex 2d8a5256c..653407279 100644--- a/apps/desktop/src/routes/(window-chrome)/settings/general.tsx+++ b/apps/desktop/src/routes/(window-chrome)/settings/general.tsx@@ -21,11 +21,13 @@ import {Show,} from "solid-js";import { createStore, reconcile } from "solid-js/store";+import toast from "solid-toast";import themePreviewAuto from "~/assets/theme-previews/auto.jpg";import themePreviewDark from "~/assets/theme-previews/dark.jpg";import themePreviewLight from "~/assets/theme-previews/light.jpg";import { Input } from "~/routes/editor/ui";import { authStore, generalSettingsStore } from "~/store";+import { clientEnv } from "~/utils/env";import {deriveGeneralSettings,type GeneralSettingsStore,@@ -117,6 +119,8 @@ const MAX_FPS_OPTIONS = [const DEFAULT_PROJECT_NAME_TEMPLATE ="{target_name} ({target_kind}) {date} {time}";+const FREE_INSTANT_MODE_MAX_RESOLUTION = 1280;+const PRO_INSTANT_MODE_MAX_RESOLUTION = 1920;export default function GeneralSettings() {const [store] = createResource(() => generalSettingsStore.get());@@ -206,6 +210,16 @@ function Inner(props: { initialStore: GeneralSettingsStore | null }) {const [settings, setSettings] = createStore<ExtendedGeneralSettingsStore>(deriveGeneralSettings(props.initialStore),);+ const auth = authStore.createQuery();+ const hasCapPro = createMemo(() => {+ const plan = auth.data?.plan;+ return !!plan && (plan.upgraded || plan.manual);+ });+ const instantModeMaxResolution = createMemo(() =>+ hasCapPro()+ ? (settings.instantModeMaxResolution ?? PRO_INSTANT_MODE_MAX_RESOLUTION)+ : FREE_INSTANT_MODE_MAX_RESOLUTION,+ );createEffect(() => {setSettings(reconcile(deriveGeneralSettings(props.initialStore)));@@ -240,6 +254,11 @@ function Inner(props: { initialStore: GeneralSettingsStore | null }) {};onMount(() => {+ commands+ .updateAuthPlan()+ .then(() => auth.refetch())+ .catch(console.error);+let pending: string | null = null;try {pending = localStorage.getItem("cap.settings.scrollToSection");@@ -494,15 +513,23 @@ function Inner(props: { initialStore: GeneralSettingsStore | null }) {</Section>)}+ <CapProSection+ hasCapPro={hasCapPro()}+ instantResolution={instantModeMaxResolution()}+ onInstantResolutionChange={(value) =>+ handleChange("instantModeMaxResolution", value)+ }+ autoOpenShareableLinks={!settings.disableAutoOpenLinks}+ onAutoOpenShareableLinksChange={(v) =>+ handleChange("disableAutoOpenLinks", !v)+ }+ />+<QualitySectionstudioQuality={settings.studioRecordingQuality ?? "balanced"}onStudioQualityChange={(value) =>handleChange("studioRecordingQuality", value)}- instantResolution={settings.instantModeMaxResolution ?? 1920}- onInstantResolutionChange={(value) =>- handleChange("instantModeMaxResolution", value)- }/><Section@@ -612,21 +639,6 @@ function Inner(props: { initialStore: GeneralSettingsStore | null }) {</SectionRows></Section>- <Section- title="Cap Pro"- description="Settings available with a Cap Pro license."- pro- >- <SectionRows>- <ToggleSettingItem- label="Auto-open shareable links"- description="Open the share link in your browser as soon as the upload finishes."- value={!settings.disableAutoOpenLinks}- onChange={(v) => handleChange("disableAutoOpenLinks", !v)}- />- </SectionRows>- </Section>-<DefaultProjectNameCardonChange={(value) =>handleChange("defaultProjectNameTemplate", value)@@ -647,7 +659,8 @@ function Inner(props: { initialStore: GeneralSettingsStore | null }) {/><ServerURLSetting- value={settings.serverUrl ?? "https://cap.so"}+ value={settings.serverUrl ?? clientEnv.VITE_SERVER_URL}+ defaultValue={clientEnv.VITE_SERVER_URL}onChange={async (v) => {const url = new URL(v);const origin = url.origin;@@ -808,64 +821,131 @@ function StudioQualitySubsection(props: {);}-function InstantQualitySubsection(props: {+function InstantQualitySetting(props: {+ hasCapPro: boolean;value: number;onChange: (value: number) => void;}) {+ const effectiveValue = createMemo(() =>+ props.hasCapPro ? props.value : FREE_INSTANT_MODE_MAX_RESOLUTION,+ );const currentTier = createMemo(() =>- INSTANT_RESOLUTION_TIERS.find((t) => t.value === props.value) ??- INSTANT_RESOLUTION_TIERS[1],+ INSTANT_RESOLUTION_TIERS.find((t) => t.value === effectiveValue()) ??+ INSTANT_RESOLUTION_TIERS[0],);+ const handleResolutionClick = async (value: number) => {+ if (props.hasCapPro || value === FREE_INSTANT_MODE_MAX_RESOLUTION) {+ props.onChange(value);+ return;+ }++ toast.custom(+ (t) => (+ <div class="flex gap-3 items-center px-4 py-3 rounded-xl border shadow-lg bg-gray-1 border-gray-4 text-gray-12">+ <p class="text-sm">+ Upgrade to Cap Pro to record Instant Mode videos above 720p.+ </p>+ <button+ type="button"+ class="px-2.5 py-1 text-xs font-medium rounded-lg transition-colors bg-blue-9 text-white hover:bg-blue-10"+ onClick={() => {+ toast.dismiss(t.id);+ void commands.showWindow("Upgrade");+ }}+ >+ Upgrade+ </button>+ </div>+ ),+ { duration: 6000 },+ );+ };return (- <div+ <SettingItemid="settings-section-instant-quality"- class="flex flex-col gap-3 px-4 py-4"+ label="Instant Mode quality"+ description={+ props.hasCapPro+ ? "Choose the maximum upload resolution for Instant recordings."+ : "Instant recordings are locked to 720p. Cap Pro unlocks higher resolutions."+ }>- <div class="flex justify-between items-start gap-4">- <div class="flex flex-col gap-0.5 min-w-0">- <p class="text-[13px] text-gray-12">Instant mode</p>- <p class="text-xs leading-snug text-gray-10">- Maximum upload resolution for Instant recordings.- </p>+ <div class="flex flex-col items-end gap-1.5">+ <div class="inline-flex p-0.5 rounded-lg border border-gray-3 bg-gray-3">+ <For each={INSTANT_RESOLUTION_TIERS}>+ {(tier) => {+ const isSelected = () => effectiveValue() === tier.value;+ return (+ <button+ type="button"+ onClick={() => void handleResolutionClick(tier.value)}+ class={cx(+ "px-3 py-1 text-xs font-medium rounded-md transition-[background-color,color,box-shadow]",+ isSelected()+ ? "bg-gray-1 text-gray-12 shadow-sm"+ : "text-gray-10 hover:text-gray-12",+ )}+ >+ {tier.label}+ </button>+ );+ }}+ </For></div>- <SegmentedControl- value={props.value}- onChange={props.onChange}- options={INSTANT_RESOLUTION_TIERS.map((tier) => ({- value: tier.value,- label: tier.label,- }))}- />- </div>- <div class="flex flex-col gap-1.5 px-3 py-2.5 rounded-lg bg-gray-3">- <p class="text-xs text-gray-12">{currentTier().summary}</p>+ <p class="text-[11px] leading-snug text-right text-gray-10">+ {currentTier().summary}+ </p></div>- </div>+ </SettingItem>+ );+}++function CapProSection(props: {+ hasCapPro: boolean;+ instantResolution: number;+ onInstantResolutionChange: (value: number) => void;+ autoOpenShareableLinks: boolean;+ onAutoOpenShareableLinksChange: (value: boolean) => void;+}) {+ return (+ <Section+ title="Cap Pro"+ description="Settings available with a Cap Pro license."+ pro+ >+ <SectionRows>+ <InstantQualitySetting+ hasCapPro={props.hasCapPro}+ value={props.instantResolution}+ onChange={props.onInstantResolutionChange}+ />+ <ToggleSettingItem+ label="Auto-open shareable links"+ description="Open the share link in your browser as soon as the upload finishes."+ value={props.autoOpenShareableLinks}+ onChange={props.onAutoOpenShareableLinksChange}+ />+ </SectionRows>+ </Section>);}function QualitySection(props: {studioQuality: StudioRecordingQuality;onStudioQualityChange: (value: StudioRecordingQuality) => void;- instantResolution: number;- onInstantResolutionChange: (value: number) => void;}) {return (<Sectiontitle="Quality"- description="Pick the right profile for each recording mode."+ description="Pick the right profile for local Studio recordings.">- <SectionCard class="divide-y divide-gray-3">+ <SectionCard><StudioQualitySubsectionvalue={props.studioQuality}onChange={props.onStudioQualityChange}/>- <InstantQualitySubsection- value={props.instantResolution}- onChange={props.onInstantResolutionChange}- /></SectionCard></Section>);@@ -873,9 +953,20 @@ function QualitySection(props: {function ServerURLSetting(props: {value: string;+ defaultValue: string;onChange: (v: string) => void;}) {const [value, setValue] = createWritableMemo(() => props.value);+ const isDefaultValue = () =>+ props.value === props.defaultValue && value() === props.defaultValue;+ const resetToDefault = () => {+ if (props.value === props.defaultValue) {+ setValue(props.defaultValue);+ return;+ }++ props.onChange(props.defaultValue);+ };return (<Section@@ -892,7 +983,15 @@ function ServerURLSetting(props: {onInput={(e) => setValue(e.currentTarget.value)}/></label>- <div class="flex justify-end">+ <div class="flex justify-end gap-2">+ <Button+ size="sm"+ variant="gray"+ disabled={isDefaultValue()}+ onClick={resetToDefault}+ >+ Reset to Default+ </Button><Buttonsize="sm"variant="dark"