From 06f6cbeb8ef0ae9c0aa75ad69ad01cb84c90b263 Mon Sep 17 00:00:00 2001 From: Fringg Date: Sat, 28 Mar 2026 23:33:06 +0300 Subject: [PATCH] fix: handle undefined inbounds/outbounds in traffic tab API may return nodes without inbounds/outbounds arrays. Made fields optional in NodeRealtimeStats and added null safety guards in TrafficTab. --- src/api/adminRemnawave.ts | 4 ++-- src/pages/AdminRemnawave.tsx | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/api/adminRemnawave.ts b/src/api/adminRemnawave.ts index dad19cf..1613a75 100644 --- a/src/api/adminRemnawave.ts +++ b/src/api/adminRemnawave.ts @@ -174,8 +174,8 @@ export interface NodeRealtimeStats { uploadBytes: number; totalBytes: number; usersOnline: number; - inbounds: InboundTraffic[]; - outbounds: InboundTraffic[]; + inbounds?: InboundTraffic[]; + outbounds?: InboundTraffic[]; } // Squads diff --git a/src/pages/AdminRemnawave.tsx b/src/pages/AdminRemnawave.tsx index 4cf8420..c2f515a 100644 --- a/src/pages/AdminRemnawave.tsx +++ b/src/pages/AdminRemnawave.tsx @@ -923,12 +923,12 @@ function TrafficTab({ data, isLoading, onRefresh }: TrafficTabProps) { {formatBytes(node.totalBytes)} - {node.inbounds.length > 0 && ( + {(node.inbounds?.length ?? 0) > 0 && (

{t('admin.remnawave.traffic.inbounds', 'Inbounds')}

- {[...node.inbounds] + {[...(node.inbounds ?? [])] .sort((a, b) => b.totalBytes - a.totalBytes) .map((ib) => (
)} - {node.outbounds.length > 0 && ( + {(node.outbounds?.length ?? 0) > 0 && (

{t('admin.remnawave.traffic.outbounds', 'Outbounds')}

- {[...node.outbounds] + {[...(node.outbounds ?? [])] .sort((a, b) => b.totalBytes - a.totalBytes) .map((ob) => (