mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-09-03 19:48:45 +00:00
FE miss WS entries (#1010)
This commit is contained in:
@@ -118,23 +118,31 @@ export const EntriesList: React.FC<EntriesListProps> = ({
|
|||||||
|
|
||||||
const scrollbarVisible = scrollableRef.current?.childWrapperRef.current.clientHeight > scrollableRef.current?.wrapperRef.current.clientHeight;
|
const scrollbarVisible = scrollableRef.current?.childWrapperRef.current.clientHeight > scrollableRef.current?.wrapperRef.current.clientHeight;
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!focusedEntryId && entries.length > 0)
|
||||||
|
setFocusedEntryId(entries[0].id);
|
||||||
|
}, [focusedEntryId, entries])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const newEntries = [...entries];
|
||||||
|
if (newEntries.length > 10000) {
|
||||||
|
setLeftOffTop(newEntries[0].id);
|
||||||
|
newEntries.splice(0, newEntries.length - 10000)
|
||||||
|
setNoMoreDataTop(false);
|
||||||
|
setEntries(newEntries);
|
||||||
|
}
|
||||||
|
}, [entries])
|
||||||
|
|
||||||
if (ws.current) {
|
if(ws.current && !ws.current.onmessage) {
|
||||||
ws.current.onmessage = (e) => {
|
ws.current.onmessage = (e) => {
|
||||||
if (!e?.data) return;
|
if (!e?.data) return;
|
||||||
const message = JSON.parse(e.data);
|
const message = JSON.parse(e.data);
|
||||||
switch (message.messageType) {
|
switch (message.messageType) {
|
||||||
case "entry":
|
case "entry":
|
||||||
const entry = message.data;
|
setEntries(entriesState => {
|
||||||
if (!focusedEntryId) setFocusedEntryId(entry.id);
|
const newEntries = [...entriesState, message.data];
|
||||||
const newEntries = [...entries, entry];
|
return newEntries;
|
||||||
if (newEntries.length > 10000) {
|
});
|
||||||
setLeftOffTop(newEntries[0].id);
|
|
||||||
newEntries.splice(0, newEntries.length - 10000)
|
|
||||||
setNoMoreDataTop(false);
|
|
||||||
}
|
|
||||||
setEntries(newEntries);
|
|
||||||
break;
|
break;
|
||||||
case "status":
|
case "status":
|
||||||
setTappingStatus(message.tappingStatus);
|
setTappingStatus(message.tappingStatus);
|
||||||
|
Reference in New Issue
Block a user