From 7918c4849d21a4b3c0e1a1568e31ff251a2ad9b3 Mon Sep 17 00:00:00 2001 From: 4gray Date: Mon, 24 Nov 2025 21:25:10 +0100 Subject: [PATCH] fix: suppress snackbar for portal status checks and log them Refactor error handling for Xtream requests to avoid showing user snackbars when the request is a portal status check (get_account_info). Instead of treating these errors as full failures, log them with console.log to indicate the portal may be unavailable and return early. Key changes: - Introduce isStatusCheck detection in electron and pwa services. - Replace console.error + snackbar with console.log for status checks. - Only display snackbars for non-status-check errors. - Add a console.log when pwa response has no payload for status checks. This prevents unnecessary user-facing error popups for routine portal health/status checks while keeping errors surfaced for other requests. --- apps/web/src/app/services/electron.service.ts | 32 +++++++++++++------ apps/web/src/app/services/pwa.service.ts | 15 +++++++-- 2 files changed, 35 insertions(+), 12 deletions(-) diff --git a/apps/web/src/app/services/electron.service.ts b/apps/web/src/app/services/electron.service.ts index 5b6cc0135..cee7b310f 100644 --- a/apps/web/src/app/services/electron.service.ts +++ b/apps/web/src/app/services/electron.service.ts @@ -226,16 +226,28 @@ export class ElectronService extends DataService { window.postMessage(result); return result; } catch (error: any) { - console.error('Xtream request error:', error.message); - this.snackBar.open( - `Error: ${error.message ?? 'Failed to connect to Xtream server'}, status: ${ - error.status ?? 500 - }`, - 'Close', - { - duration: 5000, - } - ); + const isStatusCheck = payload.params?.action === 'get_account_info'; + + // Log error to console + if (isStatusCheck) { + console.log('Portal status check failed - portal may be unavailable:', error.message || error); + } else { + console.error('Xtream request error:', error.message); + } + + // Only show snackbar for non-status-check requests + if (!isStatusCheck) { + this.snackBar.open( + `Error: ${error.message ?? 'Failed to connect to Xtream server'}, status: ${ + error.status ?? 500 + }`, + 'Close', + { + duration: 5000, + } + ); + } + return { type: ERROR, status: error.status ?? 500, diff --git a/apps/web/src/app/services/pwa.service.ts b/apps/web/src/app/services/pwa.service.ts index 000bfdda8..e4535f2e0 100644 --- a/apps/web/src/app/services/pwa.service.ts +++ b/apps/web/src/app/services/pwa.service.ts @@ -186,7 +186,10 @@ export class PwaService extends DataService { ); if (!(response as any).payload) { - if (payload.params.action === 'get_account_info') return; + if (payload.params.action === 'get_account_info') { + console.log('Portal status check failed - portal may be unavailable:', (response as any).message || 'No payload received'); + return; + } result = { type: ERROR, @@ -204,7 +207,15 @@ export class PwaService extends DataService { } return result; } catch (error: any) { - if (payload.params.action === 'get_account_info') return; + const isStatusCheck = payload.params.action === 'get_account_info'; + + // Log error to console + if (isStatusCheck) { + console.log('Portal status check failed - portal may be unavailable:', error.message || error); + return; + } + + console.error('Xtream request error:', error.message); this.snackBar.open( `Error: ${error.message ?? ' Unknown error'}, status: ${ error.status ?? 500