diff --git a/examples/apps/screenpipe-app-tauri/components/dev-dialog.tsx b/examples/apps/screenpipe-app-tauri/components/dev-dialog.tsx index 19598ca74..f818c47d9 100644 --- a/examples/apps/screenpipe-app-tauri/components/dev-dialog.tsx +++ b/examples/apps/screenpipe-app-tauri/components/dev-dialog.tsx @@ -20,7 +20,7 @@ export function DevSettings() { const [isSaving, setIsSaving] = useState(false); const { toast } = useToast(); - useEffect(() => { + React.useEffect(() => { setLocalSettings(settings); }, [settings]); @@ -36,13 +36,32 @@ export function DevSettings() { }); try { - await updateSettings(localSettings); - await new Promise((resolve) => setTimeout(resolve, 1000)); + // Create an object to store only the changed settings + const changedSettings = Object.entries(localSettings).reduce( + (acc, [key, value]) => { + if (value !== settings[key as keyof typeof settings]) { + acc[key as keyof typeof settings] = value; + } + return acc; + }, + {} as Partial + ); - toast({ - title: "dev settings updated successfully", - description: "your changes have been saved.", - }); + // Only update if there are changes + if (Object.keys(changedSettings).length > 0) { + await updateSettings(changedSettings); + await new Promise((resolve) => setTimeout(resolve, 1000)); + + toast({ + title: "dev settings updated successfully", + description: "your changes have been saved.", + }); + } else { + toast({ + title: "no changes detected", + description: "no settings were updated.", + }); + } } catch (error) { console.error("failed to update dev settings:", error); toast({ diff --git a/examples/apps/screenpipe-app-tauri/components/screenpipe-status.tsx b/examples/apps/screenpipe-app-tauri/components/screenpipe-status.tsx index ea048b667..23513a3fb 100644 --- a/examples/apps/screenpipe-app-tauri/components/screenpipe-status.tsx +++ b/examples/apps/screenpipe-app-tauri/components/screenpipe-status.tsx @@ -111,14 +111,20 @@ sqlite3 "${dbPath}" "SELECT * FROM audio_transcriptions ORDER BY timestamp DESC const DevModeSettings = () => { const { settings, updateSettings } = useSettings(); const [localSettings, setLocalSettings] = useState(settings); - const handleDevModeToggle = (checked: boolean) => { - setLocalSettings((prev) => ({ ...prev, devMode: checked })); - updateSettings({ devMode: checked }); + const handleDevModeToggle = async (checked: boolean) => { + try { + await updateSettings({ devMode: checked }); + setLocalSettings((prev) => ({ ...prev, devMode: checked })); + // ... rest of the function ... + } catch (error) { + console.error("Failed to update dev mode:", error); + // Add error handling, e.g., show a toast notification + } }; const [isLoading, setIsLoading] = useState(false); const { toast } = useToast(); - React.useEffect(() => { + useEffect(() => { setLocalSettings(settings); }, [settings]); @@ -336,21 +342,12 @@ const HealthStatus = ({ className }: { className?: string }) => { try { await invoke("open_screen_capture_preferences"); - await new Promise((resolve) => setTimeout(resolve, 2000)); - - toastId.update({ - id: toastId.id, - title: "permissions reset", - description: - "screen capture permissions have been reset. please restart the app.", - duration: 5000, - }); } catch (error) { - console.error("failed to reset screen permissions:", error); + console.error("failed to open screen permissions:", error); toastId.update({ id: toastId.id, title: "error", - description: "failed to reset screen permissions.", + description: "failed to open screen permissions.", variant: "destructive", duration: 3000, }); diff --git a/examples/apps/screenpipe-app-tauri/lib/hooks/use-health-check.tsx b/examples/apps/screenpipe-app-tauri/lib/hooks/use-health-check.tsx index 8b365245c..54b448a22 100644 --- a/examples/apps/screenpipe-app-tauri/lib/hooks/use-health-check.tsx +++ b/examples/apps/screenpipe-app-tauri/lib/hooks/use-health-check.tsx @@ -21,9 +21,16 @@ export function useHealthCheck() { throw new Error(`HTTP error! status: ${response.status} ${text}`); } const data: HealthCheckResponse = await response.json(); - if (health !== null && health.status === data.status) { + if ( + (health !== null && health.status === data.status) || + // did not change + (health != null && + health.status_code === data.status_code && + health.message === data.message) + ) { return; } + console.log("setting health", data); setHealth(data); } catch (error) { console.error("Failed to fetch health status:", error); diff --git a/examples/apps/screenpipe-app-tauri/lib/hooks/use-settings.tsx b/examples/apps/screenpipe-app-tauri/lib/hooks/use-settings.tsx index b3534cdb2..ff9c8c92d 100644 --- a/examples/apps/screenpipe-app-tauri/lib/hooks/use-settings.tsx +++ b/examples/apps/screenpipe-app-tauri/lib/hooks/use-settings.tsx @@ -61,6 +61,7 @@ let store: Store | null = null; export function useSettings() { const [settings, setSettings] = useState(defaultSettings); + // console.log("settings", settings); const resetSetting = async (key: keyof Settings) => { if (!store) { await initStore(); diff --git a/examples/apps/screenpipe-app-tauri/src-tauri/Cargo.toml b/examples/apps/screenpipe-app-tauri/src-tauri/Cargo.toml index e7f7219f2..36554cfe8 100644 --- a/examples/apps/screenpipe-app-tauri/src-tauri/Cargo.toml +++ b/examples/apps/screenpipe-app-tauri/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "screenpipe-app" -version = "0.1.70" +version = "0.1.71" description = "" authors = ["you"] license = ""