diff --git a/Cargo.lock b/Cargo.lock index fd553bd87..589df6b31 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3877,6 +3877,7 @@ dependencies = [ "serde_json", "specta", "specta-typescript", + "strum 0.26.3", "tauri", "tauri-build", "tauri-plugin-analytics", @@ -3902,6 +3903,7 @@ dependencies = [ "tauri-plugin-shell", "tauri-plugin-single-instance", "tauri-plugin-store", + "tauri-plugin-store2", "tauri-plugin-template", "tauri-plugin-tracing", "tauri-plugin-tray", @@ -14987,23 +14989,6 @@ dependencies = [ "zbus", ] -[[package]] -name = "tauri-plugin-sse" -version = "0.1.0" -dependencies = [ - "bytes", - "futures-util", - "reqwest 0.12.24", - "serde", - "specta", - "specta-typescript", - "tauri", - "tauri-plugin", - "tauri-specta", - "tokio", - "tracing", -] - [[package]] name = "tauri-plugin-store" version = "2.4.1" diff --git a/apps/desktop/src-tauri/Cargo.toml b/apps/desktop/src-tauri/Cargo.toml index 1b9cf0496..eaa917ad8 100644 --- a/apps/desktop/src-tauri/Cargo.toml +++ b/apps/desktop/src-tauri/Cargo.toml @@ -43,6 +43,7 @@ tauri-plugin-sentry = { workspace = true } tauri-plugin-shell = { workspace = true } tauri-plugin-single-instance = { workspace = true } tauri-plugin-store = { workspace = true } +tauri-plugin-store2 = { workspace = true } tauri-plugin-template = { workspace = true } tauri-plugin-tracing = { workspace = true } tauri-plugin-tray = { workspace = true } @@ -56,6 +57,7 @@ tauri-specta = { workspace = true, features = ["derive", "typescript"] } sentry = { workspace = true, features = ["tracing"] } serde = { workspace = true, features = ["derive"] } serde_json = { workspace = true } +strum = { workspace = true, features = ["derive"] } tracing = { workspace = true } aspasia = "0.2.1" diff --git a/apps/desktop/src-tauri/src/commands.rs b/apps/desktop/src-tauri/src/commands.rs index 45a99f23d..3c07bfa4e 100644 --- a/apps/desktop/src-tauri/src/commands.rs +++ b/apps/desktop/src-tauri/src/commands.rs @@ -1,3 +1,5 @@ +use crate::AppExt; + use aspasia::{Subtitle as SubtitleTrait, TimedSubtitleFile, WebVttSubtitle}; #[derive(Debug, serde::Serialize, serde::Deserialize, specta::Type)] @@ -39,3 +41,20 @@ pub async fn parse_subtitle( let sub = TimedSubtitleFile::new(&path).unwrap(); Ok(sub.into()) } + +#[tauri::command] +#[specta::specta] +pub async fn get_onboarding_needed( + app: tauri::AppHandle, +) -> Result { + app.get_onboarding_needed().map_err(|e| e.to_string()) +} + +#[tauri::command] +#[specta::specta] +pub async fn set_onboarding_needed( + app: tauri::AppHandle, + v: bool, +) -> Result<(), String> { + app.set_onboarding_needed(v).map_err(|e| e.to_string()) +} diff --git a/apps/desktop/src-tauri/src/ext.rs b/apps/desktop/src-tauri/src/ext.rs new file mode 100644 index 000000000..5a8dee6db --- /dev/null +++ b/apps/desktop/src-tauri/src/ext.rs @@ -0,0 +1,32 @@ +use crate::StoreKey; +use tauri_plugin_store2::{ScopedStore, StorePluginExt}; +pub trait AppExt { + fn desktop_store(&self) -> Result, String>; + + fn get_onboarding_needed(&self) -> Result; + fn set_onboarding_needed(&self, v: bool) -> Result<(), String>; +} + +impl> AppExt for T { + #[tracing::instrument(skip_all)] + fn desktop_store(&self) -> Result, String> { + self.scoped_store("desktop").map_err(|e| e.to_string()) + } + + #[tracing::instrument(skip_all)] + fn get_onboarding_needed(&self) -> Result { + let store = self.desktop_store()?; + store + .get(StoreKey::OnboardingNeeded2) + .map(|opt| opt.unwrap_or(true)) + .map_err(|e| e.to_string()) + } + + #[tracing::instrument(skip_all)] + fn set_onboarding_needed(&self, v: bool) -> Result<(), String> { + let store = self.desktop_store()?; + store + .set(StoreKey::OnboardingNeeded2, v) + .map_err(|e| e.to_string()) + } +} diff --git a/apps/desktop/src-tauri/src/lib.rs b/apps/desktop/src-tauri/src/lib.rs index b5db3d3f9..5836a169c 100644 --- a/apps/desktop/src-tauri/src/lib.rs +++ b/apps/desktop/src-tauri/src/lib.rs @@ -1,4 +1,9 @@ mod commands; +mod ext; +mod store; + +use ext::*; +use store::*; use tauri_plugin_windows::{AppWindow, WindowsPluginExt}; @@ -63,6 +68,7 @@ pub async fn main() { .plugin(tauri_plugin_clipboard_manager::init()) .plugin(tauri_plugin_tray::init()) .plugin(tauri_plugin_store::Builder::default().build()) + .plugin(tauri_plugin_store2::init()) .plugin(tauri_plugin_windows::init()) .plugin(tauri_plugin_autostart::init( tauri_plugin_autostart::MacosLauncher::LaunchAgent, @@ -108,15 +114,27 @@ pub async fn main() { .build(tauri::generate_context!()) .unwrap(); - if true { + { let app_handle = app.handle().clone(); - AppWindow::Main.show(&app_handle).unwrap(); + if app.get_onboarding_needed().unwrap_or(true) { + AppWindow::Main.hide(&app_handle).unwrap(); + AppWindow::Onboarding.show(&app_handle).unwrap(); + } else { + AppWindow::Onboarding.destroy(&app_handle).unwrap(); + AppWindow::Main.show(&app_handle).unwrap(); + } } app.run(|app, event| { #[cfg(target_os = "macos")] if let tauri::RunEvent::Reopen { .. } = event { - AppWindow::Main.show(app).unwrap(); + if app.get_onboarding_needed().unwrap_or(true) { + AppWindow::Main.hide(&app).unwrap(); + AppWindow::Onboarding.show(&app).unwrap(); + } else { + AppWindow::Onboarding.destroy(&app).unwrap(); + AppWindow::Main.show(&app).unwrap(); + } } }); } @@ -125,6 +143,8 @@ fn make_specta_builder() -> tauri_specta::Builder { tauri_specta::Builder::::new() .commands(tauri_specta::collect_commands![ commands::parse_subtitle::, + commands::get_onboarding_needed::, + commands::set_onboarding_needed::, ]) .error_handling(tauri_specta::ErrorHandlingMode::Result) } diff --git a/apps/desktop/src-tauri/src/store.rs b/apps/desktop/src-tauri/src/store.rs new file mode 100644 index 000000000..79c533f80 --- /dev/null +++ b/apps/desktop/src-tauri/src/store.rs @@ -0,0 +1,8 @@ +use tauri_plugin_store2::ScopedStoreKey; + +#[derive(serde::Deserialize, specta::Type, PartialEq, Eq, Hash, strum::Display)] +pub enum StoreKey { + OnboardingNeeded2, +} + +impl ScopedStoreKey for StoreKey {} diff --git a/apps/desktop/src/components/onboarding/permissions.tsx b/apps/desktop/src/components/onboarding/permissions.tsx index 0decc9f7d..7d025bb8b 100644 --- a/apps/desktop/src/components/onboarding/permissions.tsx +++ b/apps/desktop/src/components/onboarding/permissions.tsx @@ -31,7 +31,6 @@ export function Permissions({ onNext }: PermissionsProps) { onNext() }} >
; } - if (onboarding.step === "calendars") { - content = ; - } - return (
{content}
@@ -69,6 +65,7 @@ function useOnboarding() { const goNext = useCallback((params) => { if (!next) { + commands.setOnboardingNeeded(false).catch((e) => console.error(e)); windowsCommands.windowShow({ type: "main" }).then(() => { windowsCommands.windowDestroy({ type: "onboarding" }); }); diff --git a/apps/desktop/src/types/tauri.gen.ts b/apps/desktop/src/types/tauri.gen.ts index d3c9b7893..267699b89 100644 --- a/apps/desktop/src/types/tauri.gen.ts +++ b/apps/desktop/src/types/tauri.gen.ts @@ -14,6 +14,22 @@ async parseSubtitle(path: string) : Promise> { if(e instanceof Error) throw e; else return { status: "error", error: e as any }; } +}, +async getOnboardingNeeded() : Promise> { + try { + return { status: "ok", data: await TAURI_INVOKE("get_onboarding_needed") }; +} catch (e) { + if(e instanceof Error) throw e; + else return { status: "error", error: e as any }; +} +}, +async setOnboardingNeeded(v: boolean) : Promise> { + try { + return { status: "ok", data: await TAURI_INVOKE("set_onboarding_needed", { v }) }; +} catch (e) { + if(e instanceof Error) throw e; + else return { status: "error", error: e as any }; +} } } diff --git a/crates/notification/src/lib.rs b/crates/notification/src/lib.rs index dd2592b4b..7f585f94c 100644 --- a/crates/notification/src/lib.rs +++ b/crates/notification/src/lib.rs @@ -1,5 +1,4 @@ use std::collections::HashMap; -use std::process::Command; use std::sync::{Mutex, OnceLock}; use std::time::{Duration, Instant}; diff --git a/packages/utils/src/index.ts b/packages/utils/src/index.ts index 4d9835937..c25e05854 100644 --- a/packages/utils/src/index.ts +++ b/packages/utils/src/index.ts @@ -1,3 +1,2 @@ export * from "./cn"; export * from "./date"; -export * from "./fetch"; diff --git a/plugins/windows/src/ext.rs b/plugins/windows/src/ext.rs index 04de14406..5ce2336b6 100644 --- a/plugins/windows/src/ext.rs +++ b/plugins/windows/src/ext.rs @@ -45,7 +45,7 @@ impl AppWindow { app.get_webview_window(&label) } - fn hide(&self, app: &AppHandle) -> Result<(), crate::Error> { + pub fn hide(&self, app: &AppHandle) -> Result<(), crate::Error> { if let Some(window) = self.get(app) { window.hide()?; } @@ -61,7 +61,7 @@ impl AppWindow { Ok(()) } - fn destroy(&self, app: &AppHandle) -> Result<(), crate::Error> { + pub fn destroy(&self, app: &AppHandle) -> Result<(), crate::Error> { if let Some(window) = self.get(app) { window.destroy()?; }