mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-01-02 18:39:05 +01:00
fix cpu plot timing issue (#799)
This commit is contained in:
parent
31414a7536
commit
d344fd9b6d
@ -149,8 +149,11 @@ class CpuPlotViewModel {
|
|||||||
if (initialData == null) {
|
if (initialData == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const newData = this.getDefaultData();
|
||||||
const initialDataItems: DataItem[] = initialData.map(convertWaveEventToDataItem);
|
const initialDataItems: DataItem[] = initialData.map(convertWaveEventToDataItem);
|
||||||
globalStore.set(this.addDataAtom, initialDataItems);
|
// splice the initial data into the default data (replacing the newest points)
|
||||||
|
newData.splice(newData.length - initialDataItems.length, initialDataItems.length, ...initialDataItems);
|
||||||
|
globalStore.set(this.addDataAtom, newData);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log("Error loading initial data for cpuplot", e);
|
console.log("Error loading initial data for cpuplot", e);
|
||||||
} finally {
|
} finally {
|
||||||
@ -158,7 +161,7 @@ class CpuPlotViewModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getDefaultData(): Array<DataItem> {
|
getDefaultData(): DataItem[] {
|
||||||
// set it back one to avoid backwards line being possible
|
// set it back one to avoid backwards line being possible
|
||||||
const numPoints = globalStore.get(this.numPoints);
|
const numPoints = globalStore.get(this.numPoints);
|
||||||
const currentTime = Date.now() - 1000;
|
const currentTime = Date.now() - 1000;
|
||||||
@ -197,6 +200,8 @@ function CpuPlotView({ model, blockId }: CpuPlotViewProps) {
|
|||||||
lastConnName.current = connName;
|
lastConnName.current = connName;
|
||||||
model.loadInitialData();
|
model.loadInitialData();
|
||||||
}
|
}
|
||||||
|
}, [connStatus.status, connName]);
|
||||||
|
React.useEffect(() => {
|
||||||
const unsubFn = waveEventSubscribe({
|
const unsubFn = waveEventSubscribe({
|
||||||
eventType: "sysinfo",
|
eventType: "sysinfo",
|
||||||
scope: connName,
|
scope: connName,
|
||||||
@ -209,11 +214,11 @@ function CpuPlotView({ model, blockId }: CpuPlotViewProps) {
|
|||||||
addPlotData([dataItem]);
|
addPlotData([dataItem]);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
console.log("subscribe to sysinfo", connName);
|
||||||
return () => {
|
return () => {
|
||||||
unsubFn();
|
unsubFn();
|
||||||
};
|
};
|
||||||
}, [connName]);
|
}, [connName]);
|
||||||
React.useEffect(() => {}, [connName]);
|
|
||||||
if (connStatus?.status != "connected") {
|
if (connStatus?.status != "connected") {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user