mirror of
https://github.com/zoriya/flood.git
synced 2026-06-09 13:01:54 +00:00
TransferRateGraph: fix blank graph in some cases
This commit is contained in:
@@ -10,14 +10,14 @@ import type {TransferRateGraphEventHandlers, TransferRateGraphInspectorPoint} fr
|
||||
|
||||
const TransferData: FC = observer(() => {
|
||||
const [graphInspectorPoint, setGraphInspectorPoint] = useState<TransferRateGraphInspectorPoint | null>(null);
|
||||
const [sidebarWidth, setSidebarWidth] = useState<number>(0);
|
||||
const [sidebarWidth, setSidebarWidth] = useState<number>(250);
|
||||
const rateGraphHandlerRefs = useRef<TransferRateGraphEventHandlers>(null);
|
||||
|
||||
return (
|
||||
<Measure
|
||||
offset
|
||||
onResize={(contentRect) => {
|
||||
if (contentRect.offset != null) {
|
||||
if (contentRect.offset?.width) {
|
||||
setSidebarWidth(contentRect.offset.width);
|
||||
}
|
||||
}}
|
||||
|
||||
@@ -6,9 +6,9 @@ export const TRANSFER_DIRECTIONS: Readonly<Array<TransferDirection>> = ['downloa
|
||||
|
||||
class TransferDataStore {
|
||||
transferRates: TransferHistory = {
|
||||
download: new Array(30).fill(0),
|
||||
upload: new Array(30).fill(0),
|
||||
timestamps: new Array(30).fill(Date.now()),
|
||||
download: [0, 0],
|
||||
upload: [0, 0],
|
||||
timestamps: [Date.now() - 5000, Date.now()],
|
||||
};
|
||||
|
||||
transferSummary: TransferSummary = {
|
||||
@@ -41,7 +41,9 @@ class TransferDataStore {
|
||||
}
|
||||
|
||||
handleFetchTransferHistorySuccess(transferData: TransferHistory) {
|
||||
this.transferRates = transferData;
|
||||
if (transferData.timestamps.length > 1) {
|
||||
this.transferRates = transferData;
|
||||
}
|
||||
}
|
||||
|
||||
handleTransferSummaryFullUpdate(transferSummary: TransferSummary) {
|
||||
|
||||
Reference in New Issue
Block a user