Skip to content

Commit df6ee00

Browse files
committed
fix(web): report a new snapshot failure and recheck the setting before delivery
1 parent 3b2307c commit df6ee00

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

‎apps/web/src/components/desktop/SnapShotCoordinator.tsx‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,8 @@ export function SnapShotCoordinator() {
214214
const drainingRef = useRef<Promise<void> | null>(null);
215215
const rerunRequestedRef = useRef(false);
216216
const soundedCaptureIdsRef = useRef(new Set<string>());
217-
// Undelivered captures stay pending and every drain revisits them, so report each one once.
218-
const reportedCaptureIdsRef = useRef(new Set<string>());
217+
// Undelivered captures stay pending and every drain revisits them, so report each failure once.
218+
const reportedCaptureFailuresRef = useRef(new Map<string, unknown>());
219219
const pendingAnimationStartsRef = useRef(new Set<string>());
220220

221221
const currentTarget = routeThreadRef ?? routeDraftId;
@@ -261,8 +261,8 @@ export function SnapShotCoordinator() {
261261
);
262262

263263
const reportOnce = useCallback((id: string, toast: Parameters<typeof toastManager.add>[0]) => {
264-
if (reportedCaptureIdsRef.current.has(id)) return;
265-
reportedCaptureIdsRef.current.add(id);
264+
if (reportedCaptureFailuresRef.current.get(id) === toast.title) return;
265+
reportedCaptureFailuresRef.current.set(id, toast.title);
266266
toastManager.add(toast);
267267
}, []);
268268

@@ -288,6 +288,7 @@ export function SnapShotCoordinator() {
288288
item.id,
289289
resolveCaptureTarget,
290290
);
291+
if (!getClientSettings().snapShotEnabled) return;
291292
const target = capturedTarget
292293
? resolveExistingSnapShotTarget(capturedTarget, routeThreadRef)
293294
: null;
@@ -308,7 +309,7 @@ export function SnapShotCoordinator() {
308309
await deliverSnapShot(bridge, item, target);
309310
captureTargetsRef.current.delete(item.id);
310311
soundedCaptureIdsRef.current.delete(item.id);
311-
reportedCaptureIdsRef.current.delete(item.id);
312+
reportedCaptureFailuresRef.current.delete(item.id);
312313
} catch (error) {
313314
await dismissSnapShotAnimation(item.id);
314315
reportOnce(

0 commit comments

Comments
 (0)