Fix settings query store and analytics

This commit is contained in:
Gregory Schier
2024-03-19 10:23:21 -07:00
parent a5dd3beb73
commit 1993361f87
4 changed files with 6 additions and 9 deletions

View File

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

View File

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

View File

@@ -11,8 +11,9 @@ export function useSettings() {
useQuery({
queryKey: settingsQueryKey(),
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 });
},
onMutate: async (settings) => {
queryClient.setQueryData<Settings>(settingsQueryKey(), settings);
queryClient.setQueryData<Settings[]>(settingsQueryKey(), [settings]);
},
});
}