Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion apps/desktop/src-tauri/src/presets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand All @@ -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),
Expand Down
18 changes: 13 additions & 5 deletions apps/desktop/src/routes/editor/PresetsDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -45,15 +45,24 @@ 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>
as={KDropdownMenu.SubTrigger}
class="h-[2.5rem]"
onFocusIn={() => setShowSettings(false)}
onClick={() => {
setShowSettings(false);
setProject(reconcile(preset.config));
applyPreset();
}}
>
<span class="mr-auto">{preset.name}</span>
Expand Down Expand Up @@ -88,8 +97,7 @@ export function PresetsDropdown() {
>
<DropdownItem
onSelect={() => {
setShowSettings(false);
setProject(reconcile(preset.config));
applyPreset();
}}
>
Apply
Expand Down