diff --git a/src/renderer/components/GlobalEffects.test.tsx b/src/renderer/components/GlobalEffects.test.tsx
index 1c25503a7..6b64954dc 100644
--- a/src/renderer/components/GlobalEffects.test.tsx
+++ b/src/renderer/components/GlobalEffects.test.tsx
@@ -38,6 +38,15 @@ describe('renderer/components/GlobalEffects.tsx', () => {
expect(setTrayIconColorAndTitleSpy).toHaveBeenCalledWith(-1, true);
});
+ it('does not report an error to the tray while the query is offline', async () => {
+ await act(async () => {
+ renderWithProviders(, { status: 'offline', notificationCount: 3 });
+ });
+
+ expect(setTrayIconColorAndTitleSpy).toHaveBeenCalledWith(3, true);
+ expect(setTrayIconColorAndTitleSpy).not.toHaveBeenCalledWith(-1, true);
+ });
+
it('resets all stores when the app is reset', async () => {
await act(async () => {
renderWithProviders(, {
diff --git a/src/renderer/routes/Notifications.test.tsx b/src/renderer/routes/Notifications.test.tsx
index d006dda72..86210579b 100644
--- a/src/renderer/routes/Notifications.test.tsx
+++ b/src/renderer/routes/Notifications.test.tsx
@@ -80,6 +80,17 @@ describe('renderer/routes/Notifications.tsx', () => {
expect(screen.queryByText('Loading')).not.toBeInTheDocument();
});
+ it('prefers the offline status over loading while the device is online', () => {
+ renderWithProviders(, {
+ status: 'offline',
+ isOnline: true,
+ });
+
+ expect(screen.getByText('Oops')).toBeInTheDocument();
+ expect(screen.queryByText('Loading')).not.toBeInTheDocument();
+ expect(screen.queryByText('AllRead')).not.toBeInTheDocument();
+ });
+
it('prefers the error state over loading', () => {
renderWithProviders(, {
globalError: getErrorDetails('UNKNOWN'),
diff --git a/src/renderer/routes/Notifications.tsx b/src/renderer/routes/Notifications.tsx
index 93441ddc5..2972aa070 100644
--- a/src/renderer/routes/Notifications.tsx
+++ b/src/renderer/routes/Notifications.tsx
@@ -35,7 +35,7 @@ export function NotificationsRoute() {
[visibleNotifications],
);
- if (!isOnline) {
+ if (!isOnline || status === 'offline') {
return ;
}
diff --git a/src/renderer/types.ts b/src/renderer/types.ts
index 2fb4c5d4e..e40e21bbf 100644
--- a/src/renderer/types.ts
+++ b/src/renderer/types.ts
@@ -52,7 +52,7 @@ export function toLinkOrNull(value: string | null | undefined): Link | null {
export type SearchToken = Branded;
-export type Status = 'loading' | 'success' | 'error';
+export type Status = 'loading' | 'offline' | 'success' | 'error';
export type Percentage = Branded;
diff --git a/src/renderer/utils/notifications/status.test.ts b/src/renderer/utils/notifications/status.test.ts
index c5abc40b6..ff20a23e6 100644
--- a/src/renderer/utils/notifications/status.test.ts
+++ b/src/renderer/utils/notifications/status.test.ts
@@ -26,8 +26,27 @@ describe('renderer/utils/notifications/status.ts', () => {
expect(deriveStatus({ ...baseInput, isLoading: true, notifications: [] })).toBe('loading');
});
- it('reports error when the query is paused (offline)', () => {
- expect(deriveStatus({ ...baseInput, isPaused: true, notifications: [clean] })).toBe('error');
+ it('reports offline when the query is paused', () => {
+ expect(deriveStatus({ ...baseInput, isPaused: true, notifications: [clean] })).toBe(
+ 'offline',
+ );
+ });
+
+ it('reports offline rather than error when paused with account errors', () => {
+ expect(
+ deriveStatus({ ...baseInput, isPaused: true, notifications: [networkError, networkError] }),
+ ).toBe('offline');
+ });
+
+ it('reports offline before the initial fetch settles when paused', () => {
+ expect(
+ deriveStatus({
+ ...baseInput,
+ isLoading: true,
+ isPaused: true,
+ notifications: [],
+ }),
+ ).toBe('offline');
});
it('reports error when the query failed', () => {
diff --git a/src/renderer/utils/notifications/status.ts b/src/renderer/utils/notifications/status.ts
index 07fad08ea..66a17da31 100644
--- a/src/renderer/utils/notifications/status.ts
+++ b/src/renderer/utils/notifications/status.ts
@@ -28,6 +28,10 @@ export interface NotificationStatusInput {
*
* Only the initial fetch (no settled success or error yet) reports `loading` -
* background refetches of already-settled data keep their settled status.
+ *
+ * A paused query means there is no connectivity, not that a fetch failed, so it
+ * reports `offline` rather than `error`. This keeps the tray and notifications
+ * view from showing a failure while the app is offline or reconnecting.
*/
export function deriveStatus({
isLoading,
@@ -35,12 +39,15 @@ export function deriveStatus({
isError,
notifications,
}: NotificationStatusInput): Status {
+ if (isPaused) {
+ return 'offline';
+ }
+
if (isLoading) {
return 'loading';
}
- // Paused (offline) and outright query errors both surface as error status.
- if (isPaused || isError) {
+ if (isError) {
return 'error';
}