-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: new settings in app, notification when unhealthy
- Loading branch information
1 parent
7d37c19
commit 38676ec
Showing
6 changed files
with
184 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -163,27 +163,21 @@ jobs: | |
projectPath: "./examples/apps/screenpipe-app-tauri" | ||
tauriScript: bunx tauri -v | ||
|
||
- name: Get version from Cargo.toml | ||
id: get_version | ||
run: | | ||
VERSION=$(grep '^version =' examples/apps/screenpipe-app-tauri/src-tauri/Cargo.toml | sed 's/.*= "\(.*\)"/\1/') | ||
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT | ||
- name: Create CrabNebula Cloud Release Draft | ||
uses: crabnebula-dev/[email protected] | ||
with: | ||
command: release draft ${{ secrets.CN_APP_SLUG }} --framework tauri ${{ steps.get_version.outputs.VERSION }} | ||
command: release draft ${{ secrets.CN_APP_SLUG }} --framework tauri | ||
api-key: ${{ secrets.CN_API_KEY }} | ||
|
||
- name: Upload Assets to CrabNebula Cloud | ||
uses: crabnebula-dev/[email protected] | ||
with: | ||
command: release upload ${{ secrets.CN_APP_SLUG }} --framework tauri ${{ steps.get_version.outputs.VERSION }} | ||
command: release upload ${{ secrets.CN_APP_SLUG }} --framework tauri | ||
api-key: ${{ secrets.CN_API_KEY }} | ||
path: ./examples/apps/screenpipe-app-tauri/src-tauri | ||
|
||
- name: Publish CrabNebula Cloud Release | ||
uses: crabnebula-dev/[email protected] | ||
with: | ||
command: release publish ${{ secrets.CN_APP_SLUG }} --framework tauri ${{ steps.get_version.outputs.VERSION }} | ||
command: release publish ${{ secrets.CN_APP_SLUG }} --framework tauri | ||
api-key: ${{ secrets.CN_API_KEY }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 57 additions & 20 deletions
77
examples/apps/screenpipe-app-tauri/lib/hooks/use-settings.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,81 @@ | ||
import { useState, useEffect } from "react"; | ||
import { Store } from "@tauri-apps/plugin-store"; | ||
import { homeDir } from "@tauri-apps/api/path"; | ||
import { join } from "@tauri-apps/api/path"; | ||
|
||
interface Settings { | ||
openaiApiKey: string; | ||
useOllama: boolean; | ||
isLoading: boolean; | ||
useCli: boolean; | ||
useCloudAudio: boolean; | ||
} | ||
|
||
let store: Store | null = null; | ||
|
||
export function useSettings() { | ||
const [settings, setSettings] = useState<Settings>({ | ||
openaiApiKey: "", | ||
useOllama: false, | ||
isLoading: true, | ||
useCli: false, | ||
useCloudAudio: true, | ||
}); | ||
|
||
useEffect(() => { | ||
const loadSettings = () => { | ||
const savedKey = localStorage.getItem("openaiApiKey") || ""; | ||
const savedUseOllama = localStorage.getItem("useOllama") === "true"; | ||
const savedUseCli = localStorage.getItem("useCli") === "true"; | ||
setSettings({ | ||
openaiApiKey: savedKey, | ||
useOllama: savedUseOllama, | ||
isLoading: false, | ||
useCli: savedUseCli, | ||
}); | ||
const initStore = async () => { | ||
const home = await homeDir(); | ||
const storePath = await join(home, ".screenpipe", "store.bin"); | ||
store = new Store(storePath); | ||
}; | ||
|
||
const loadSettings = async () => { | ||
if (!store) { | ||
await initStore(); | ||
} | ||
|
||
try { | ||
await store!.load(); | ||
const savedKey = ((await store!.get("openaiApiKey")) as string) || ""; | ||
const savedUseOllama = | ||
((await store!.get("useOllama")) as boolean) || false; | ||
const savedUseCloudAudio = | ||
((await store!.get("useCloudAudio")) as boolean) ?? true; | ||
|
||
setSettings({ | ||
openaiApiKey: savedKey, | ||
useOllama: savedUseOllama, | ||
isLoading: false, | ||
useCloudAudio: savedUseCloudAudio, | ||
}); | ||
} catch (error) { | ||
console.error("Failed to load settings:", error); | ||
setSettings((prevSettings) => ({ ...prevSettings, isLoading: false })); | ||
} | ||
}; | ||
loadSettings(); | ||
}, []); | ||
|
||
const updateSettings = (newSettings: Partial<Settings>) => { | ||
setSettings((prevSettings) => { | ||
const updatedSettings = { ...prevSettings, ...newSettings }; | ||
localStorage.setItem("openaiApiKey", updatedSettings.openaiApiKey); | ||
localStorage.setItem("useOllama", updatedSettings.useOllama.toString()); | ||
localStorage.setItem("useCli", updatedSettings.useCli.toString()); | ||
return updatedSettings; | ||
}); | ||
const updateSettings = async (newSettings: Partial<Settings>) => { | ||
if (!store) { | ||
await initStore(); | ||
} | ||
|
||
try { | ||
const updatedSettings = { ...settings, ...newSettings }; | ||
await store!.set("openaiApiKey", updatedSettings.openaiApiKey); | ||
await store!.set("useOllama", updatedSettings.useOllama); | ||
await store!.set("useCloudAudio", updatedSettings.useCloudAudio); | ||
await store!.save(); | ||
setSettings(updatedSettings); | ||
} catch (error) { | ||
console.error("Failed to update settings:", error); | ||
} | ||
}; | ||
|
||
return { settings, updateSettings }; | ||
} | ||
|
||
async function initStore() { | ||
const home = await homeDir(); | ||
const storePath = await join(home, ".screenpipe", "store.bin"); | ||
store = new Store(storePath); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.