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
24 changes: 24 additions & 0 deletions apps/desktop/src/components/toast/shared.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,27 @@ export function enhanceFailedToast() {
duration: 3000,
});
}

export function recordingStartFailedToast() {
const id = "recording-start-failed";

const handleClick = () => {
windowsCommands.windowShow({ type: "settings" });
sonnerToast.dismiss(id);
};

toast({
id,
title: "Failed to start recording",
content: (
<div className="space-y-1">
<div>Recording could not be started. Check your audio settings.</div>
<Button variant="default" onClick={handleClick}>
Open Settings
</Button>
</div>
),
dismissible: true,
duration: 5000,
});
}
7 changes: 6 additions & 1 deletion apps/desktop/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { CatchBoundary, createRouter, ErrorComponent, RouterProvider } from "@ta
import { useEffect } from "react";
import ReactDOM from "react-dom/client";

import { recordingStartFailedToast } from "@/components/toast/shared";
import type { Context } from "@/types";
import { commands } from "@/types";
import { commands as authCommands } from "@hypr/plugin-auth";
Expand Down Expand Up @@ -44,7 +45,11 @@ const queryClient = new QueryClient({
});

const sessionsStore = createSessionsStore();
const ongoingSessionStore = createOngoingSessionStore(sessionsStore);
const ongoingSessionStore = createOngoingSessionStore(sessionsStore, {
onRecordingStartFailed: (error) => {
recordingStartFailedToast();
},
});

const context: Context = {
queryClient,
Expand Down
14 changes: 13 additions & 1 deletion packages/utils/src/stores/ongoing-session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,14 @@ const initialState: State = {

export type OngoingSessionStore = ReturnType<typeof createOngoingSessionStore>;

export const createOngoingSessionStore = (sessionsStore: ReturnType<typeof createSessionsStore>) => {
type OngoingSessionCallbacks = {
onRecordingStartFailed?: (error: any) => void;
};

export const createOngoingSessionStore = (
sessionsStore: ReturnType<typeof createSessionsStore>,
callbacks?: OngoingSessionCallbacks,
) => {
return createStore<State & Actions>((set, get) => ({
...initialState,
get: () => get(),
Expand Down Expand Up @@ -130,6 +137,11 @@ export const createOngoingSessionStore = (sessionsStore: ReturnType<typeof creat
}).catch((error) => {
console.error(error);
set(initialState);

// Notify user about recording failure
if (callbacks?.onRecordingStartFailed) {
callbacks.onRecordingStartFailed(error);
}
});
},
stop: () => {
Expand Down