From ed947f62a26c30a6f30aaf73066d7aea6f520bb0 Mon Sep 17 00:00:00 2001 From: kunish Date: Sun, 17 Sep 2023 21:18:23 +0800 Subject: [PATCH] fix(proxy): wrap subscription info usage percentage with toFinite --- src/components/SubscriptionInfo.tsx | 5 +++-- src/pages/Connections.tsx | 1 + src/pages/Logs.tsx | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/components/SubscriptionInfo.tsx b/src/components/SubscriptionInfo.tsx index 89a9735..5adb83f 100644 --- a/src/components/SubscriptionInfo.tsx +++ b/src/components/SubscriptionInfo.tsx @@ -1,5 +1,6 @@ import byteSize from 'byte-size' import dayjs from 'dayjs' +import { toFinite } from 'lodash' import type { SubscriptionInfo as ISubscriptionInfo } from '~/types' const getSubscriptionsInfo = (subscriptionInfo: ISubscriptionInfo) => { @@ -9,10 +10,10 @@ const getSubscriptionsInfo = (subscriptionInfo: ISubscriptionInfo) => { const used = byteSize(Download + Upload, { units: 'iec', }) - const percentage = (((Download + Upload) / Total) * 100).toFixed(2) + const percentage = toFinite((((Download + Upload) / Total) * 100).toFixed(2)) const expireStr = () => { - if (subscriptionInfo.Expire === 0) { + if (Expire === 0) { return 'Null' } diff --git a/src/pages/Connections.tsx b/src/pages/Connections.tsx index b2415b5..9103456 100644 --- a/src/pages/Connections.tsx +++ b/src/pages/Connections.tsx @@ -422,6 +422,7 @@ export default () => { {(cell) => { return ( { e.preventDefault() diff --git a/src/pages/Logs.tsx b/src/pages/Logs.tsx index 9b480ef..bfcc28e 100644 --- a/src/pages/Logs.tsx +++ b/src/pages/Logs.tsx @@ -204,10 +204,10 @@ export default () => { {(row) => ( - + {(cell) => ( - + {flexRender( cell.column.columnDef.cell, cell.getContext(),