Fix settings query store and analytics

This commit is contained in:
Gregory Schier
2024-03-19 10:23:21 -07:00
parent 9797bc1830
commit 0e1153fdfd
4 changed files with 6 additions and 9 deletions

View File

@@ -26,6 +26,7 @@ pub enum AnalyticsResource {
KeyValue, KeyValue,
Sidebar, Sidebar,
Workspace, Workspace,
Setting,
} }
impl AnalyticsResource { impl AnalyticsResource {

View File

@@ -914,16 +914,11 @@ async fn cmd_track_event(
analytics::track_event(&window.app_handle(), resource, action, attributes).await; analytics::track_event(&window.app_handle(), resource, action, attributes).await;
} }
(r, a) => { (r, a) => {
println!(
"HttpRequest: {:?}",
serde_json::to_string(&AnalyticsResource::HttpRequest)
);
println!("Send: {:?}", serde_json::to_string(&AnalyticsAction::Send));
error!( error!(
"Invalid action/resource for track_event: {resource}.{action} = {:?}.{:?}", "Invalid action/resource for track_event: {resource}.{action} = {:?}.{:?}",
r, a r, a
); );
return Err("Invalid event".to_string()); return Err("Invalid analytics event".to_string());
} }
}; };
Ok(()) Ok(())

View File

@@ -11,8 +11,9 @@ export function useSettings() {
useQuery({ useQuery({
queryKey: settingsQueryKey(), queryKey: settingsQueryKey(),
queryFn: async () => { queryFn: async () => {
return (await invoke('cmd_get_settings')) as Settings; const settings = (await invoke('cmd_get_settings')) as Settings;
return [settings];
}, },
}).data ?? undefined }).data?.[0] ?? undefined
); );
} }

View File

@@ -11,7 +11,7 @@ export function useUpdateSettings() {
await invoke('cmd_update_settings', { settings }); await invoke('cmd_update_settings', { settings });
}, },
onMutate: async (settings) => { onMutate: async (settings) => {
queryClient.setQueryData<Settings>(settingsQueryKey(), settings); queryClient.setQueryData<Settings[]>(settingsQueryKey(), [settings]);
}, },
}); });
} }