Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 2 additions & 17 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions apps/desktop/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand All @@ -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"
Expand Down
19 changes: 19 additions & 0 deletions apps/desktop/src-tauri/src/commands.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use crate::AppExt;

use aspasia::{Subtitle as SubtitleTrait, TimedSubtitleFile, WebVttSubtitle};

#[derive(Debug, serde::Serialize, serde::Deserialize, specta::Type)]
Expand Down Expand Up @@ -39,3 +41,20 @@ pub async fn parse_subtitle<R: tauri::Runtime>(
let sub = TimedSubtitleFile::new(&path).unwrap();
Ok(sub.into())
}

#[tauri::command]
#[specta::specta]
pub async fn get_onboarding_needed<R: tauri::Runtime>(
app: tauri::AppHandle<R>,
) -> Result<bool, String> {
app.get_onboarding_needed().map_err(|e| e.to_string())
}

#[tauri::command]
#[specta::specta]
pub async fn set_onboarding_needed<R: tauri::Runtime>(
app: tauri::AppHandle<R>,
v: bool,
) -> Result<(), String> {
app.set_onboarding_needed(v).map_err(|e| e.to_string())
}
32 changes: 32 additions & 0 deletions apps/desktop/src-tauri/src/ext.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
use crate::StoreKey;
use tauri_plugin_store2::{ScopedStore, StorePluginExt};
pub trait AppExt<R: tauri::Runtime> {
fn desktop_store(&self) -> Result<ScopedStore<R, crate::StoreKey>, String>;

fn get_onboarding_needed(&self) -> Result<bool, String>;
fn set_onboarding_needed(&self, v: bool) -> Result<(), String>;
}

impl<R: tauri::Runtime, T: tauri::Manager<R>> AppExt<R> for T {
#[tracing::instrument(skip_all)]
fn desktop_store(&self) -> Result<ScopedStore<R, crate::StoreKey>, String> {
self.scoped_store("desktop").map_err(|e| e.to_string())
}

#[tracing::instrument(skip_all)]
fn get_onboarding_needed(&self) -> Result<bool, String> {
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())
}
}
26 changes: 23 additions & 3 deletions apps/desktop/src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
mod commands;
mod ext;
mod store;

use ext::*;
use store::*;

use tauri_plugin_windows::{AppWindow, WindowsPluginExt};

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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();
}
}
});
}
Expand All @@ -125,6 +143,8 @@ fn make_specta_builder<R: tauri::Runtime>() -> tauri_specta::Builder<R> {
tauri_specta::Builder::<R>::new()
.commands(tauri_specta::collect_commands![
commands::parse_subtitle::<tauri::Wry>,
commands::get_onboarding_needed::<tauri::Wry>,
commands::set_onboarding_needed::<tauri::Wry>,
])
.error_handling(tauri_specta::ErrorHandlingMode::Result)
}
Expand Down
8 changes: 8 additions & 0 deletions apps/desktop/src-tauri/src/store.rs
Original file line number Diff line number Diff line change
@@ -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 {}
1 change: 0 additions & 1 deletion apps/desktop/src/components/onboarding/permissions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export function Permissions({ onNext }: PermissionsProps) {
<OnboardingContainer
title="Just three quick permissions before we begin"
description="After you grant system audio access, app will restart to apply the changes"
action={{ kind: "next", hide: !allPermissionsGranted, onClick: () => onNext() }}
>
<div className="flex flex-col gap-4">
<PermissionRow
Expand Down
11 changes: 4 additions & 7 deletions apps/desktop/src/routes/app/onboarding/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import { commands as windowsCommands } from "@hypr/plugin-windows";
import { createFileRoute, useNavigate } from "@tanstack/react-router";
import { z } from "zod";

import { Calendars } from "../../../components/onboarding/calendar";
import { Permissions } from "../../../components/onboarding/permissions";
import type { OnboardingNext } from "../../../components/onboarding/shared";
import { Welcome } from "../../../components/onboarding/welcome";
import { commands } from "../../../types/tauri.gen";

const STEPS = ["welcome", "calendars", "permissions"] as const;
const STEPS = ["welcome", "permissions"] as const;

const validateSearch = z.object({
step: z.enum(STEPS).default("welcome"),
Expand All @@ -37,14 +37,10 @@ function Component() {
content = <Permissions onNext={onboarding.goNext} />;
}

if (onboarding.step === "calendars") {
content = <Calendars local={onboarding.local} onNext={onboarding.goNext} />;
}

return (
<div
data-tauri-drag-region
className="flex h-full items-center justify-center px-8 py-12"
className="flex h-full items-center justify-center px-8 pt-20 pb-12"
>
{content}
</div>
Expand All @@ -69,6 +65,7 @@ function useOnboarding() {

const goNext = useCallback<OnboardingNext>((params) => {
if (!next) {
commands.setOnboardingNeeded(false).catch((e) => console.error(e));
windowsCommands.windowShow({ type: "main" }).then(() => {
windowsCommands.windowDestroy({ type: "onboarding" });
});
Expand Down
16 changes: 16 additions & 0 deletions apps/desktop/src/types/tauri.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,22 @@ async parseSubtitle(path: string) : Promise<Result<Subtitle, string>> {
if(e instanceof Error) throw e;
else return { status: "error", error: e as any };
}
},
async getOnboardingNeeded() : Promise<Result<boolean, string>> {
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<Result<null, string>> {
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 };
}
}
}

Expand Down
1 change: 0 additions & 1 deletion crates/notification/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::collections::HashMap;
use std::process::Command;
use std::sync::{Mutex, OnceLock};
use std::time::{Duration, Instant};

Expand Down
1 change: 0 additions & 1 deletion packages/utils/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export * from "./cn";
export * from "./date";
export * from "./fetch";
4 changes: 2 additions & 2 deletions plugins/windows/src/ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl AppWindow {
app.get_webview_window(&label)
}

fn hide(&self, app: &AppHandle<tauri::Wry>) -> Result<(), crate::Error> {
pub fn hide(&self, app: &AppHandle<tauri::Wry>) -> Result<(), crate::Error> {
if let Some(window) = self.get(app) {
window.hide()?;
}
Expand All @@ -61,7 +61,7 @@ impl AppWindow {
Ok(())
}

fn destroy(&self, app: &AppHandle<tauri::Wry>) -> Result<(), crate::Error> {
pub fn destroy(&self, app: &AppHandle<tauri::Wry>) -> Result<(), crate::Error> {
if let Some(window) = self.get(app) {
window.destroy()?;
}
Expand Down
Loading