Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

presets fixes (#563)

Brendan Allan8c0f8af53fdb
diff --git a/apps/desktop/src-tauri/src/presets.rs b/apps/desktop/src-tauri/src/presets.rs
index 3b846e943..56ba8db4d 100644
--- a/apps/desktop/src-tauri/src/presets.rs
+++ b/apps/desktop/src-tauri/src/presets.rs
@@ -4,6 +4,7 @@ use serde_json::json;
use specta::Type;
use tauri::{AppHandle, Wry};
use tauri_plugin_store::StoreExt;
+use tracing::error;
#[derive(Serialize, Deserialize, Type, Debug, Default)]
#[serde(rename_all = "camelCase")]
@@ -26,7 +27,10 @@ impl PresetsStore {
// Handle potential deserialization errors gracefully
match serde_json::from_value(store) {
Ok(settings) => Ok(Some(settings)),
- Err(_) => Err("Failed to deserialize presets store".to_string()),
+ Err(_) => {
+ error!("Failed to deserialize presets store");
+ Ok(None)
+ }
}
}
_ => Ok(None),
diff --git a/apps/desktop/src/routes/editor/PresetsDropdown.tsx b/apps/desktop/src/routes/editor/PresetsDropdown.tsx
index a779d2df0..75a4e545d 100644
--- a/apps/desktop/src/routes/editor/PresetsDropdown.tsx
+++ b/apps/desktop/src/routes/editor/PresetsDropdown.tsx
@@ -14,7 +14,7 @@ import {
} from "./ui";
export function PresetsDropdown() {
- const { setDialog, presets, setProject } = useEditorContext();
+ const { setDialog, presets, setProject, project } = useEditorContext();
return (
<KDropdownMenu gutter={8} placement="bottom">
<EditorButton<typeof KDropdownMenu.Trigger>
@@ -45,6 +45,16 @@ export function PresetsDropdown() {
{(preset, i) => {
const [showSettings, setShowSettings] = createSignal(false);
+ function applyPreset() {
+ setShowSettings(false);
+ setProject(
+ reconcile({
+ ...preset.config,
+ timeline: project.timeline,
+ })
+ );
+ }
+
return (
<KDropdownMenu.Sub gutter={16}>
<MenuItem<typeof KDropdownMenu.SubTrigger>
@@ -52,8 +62,7 @@ export function PresetsDropdown() {
class="h-[2.5rem]"
onFocusIn={() => setShowSettings(false)}
onClick={() => {
- setShowSettings(false);
- setProject(reconcile(preset.config));
+ applyPreset();
}}
>
<span class="mr-auto">{preset.name}</span>
@@ -88,8 +97,7 @@ export function PresetsDropdown() {
>
<DropdownItem
onSelect={() => {
- setShowSettings(false);
- setProject(reconcile(preset.config));
+ applyPreset();
}}
>
Apply