Skip to content

Commit 389972a

Browse files
committed
ota update
1 parent eadeb36 commit 389972a

File tree

1 file changed

+25
-2
lines changed
  • apps/desktop/src/components/toast

1 file changed

+25
-2
lines changed

apps/desktop/src/components/toast/ota.tsx

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ import { message } from "@tauri-apps/plugin-dialog";
77
import { exists } from "@tauri-apps/plugin-fs";
88
import { relaunch } from "@tauri-apps/plugin-process";
99
import { check } from "@tauri-apps/plugin-updater";
10-
import { useEffect } from "react";
10+
import { useEffect, useRef } from "react";
1111

1212
import { sonnerToast, toast } from "@hypr/ui/components/ui/toast";
13+
import { useOngoingSession } from "@hypr/utils/contexts";
1314
import { DownloadProgress } from "./shared";
1415

1516
// exported for manual update checks
@@ -82,6 +83,15 @@ export async function handleUpdateInstall(update: any, toastId: string, appInApp
8283
// ---export ends---
8384

8485
export default function OtaNotification() {
86+
// Track dismissed update versions to prevent showing same notification repeatedly
87+
const dismissedVersions = useRef(new Set<string>());
88+
89+
// Check if there's an active meeting session
90+
const ongoingSession = useOngoingSession((state) => ({
91+
status: state.status,
92+
sessionId: state.sessionId,
93+
}));
94+
8595
const appInApplicationsFolder = useQuery({
8696
queryKey: ["app-in-applications-folder"],
8797
queryFn: async () => {
@@ -111,6 +121,19 @@ export default function OtaNotification() {
111121

112122
const update = checkForUpdate.data;
113123

124+
// Don't show notification if this version was already dismissed
125+
if (dismissedVersions.current.has(update.version)) {
126+
return;
127+
}
128+
129+
// Don't show update notifications during active meetings
130+
if (ongoingSession.status === "running_active" || ongoingSession.status === "running_paused") {
131+
return;
132+
}
133+
134+
// Mark this version as shown
135+
dismissedVersions.current.add(update.version);
136+
114137
toast({
115138
id: "ota-notification",
116139
title: "Update Available",
@@ -169,7 +192,7 @@ export default function OtaNotification() {
169192
],
170193
dismissible: true,
171194
});
172-
}, [checkForUpdate.data]);
195+
}, [checkForUpdate.data, ongoingSession.status]);
173196

174197
return null;
175198
}

0 commit comments

Comments
 (0)