refresh events when first websocket event streams

This commit is contained in:
Keith J. Grant
2022-10-18 13:53:27 -07:00
committed by Keith J. Grant
parent ac9871b36f
commit 6f6f04a071

View File

@@ -251,6 +251,9 @@ function JobOutput({ job, eventRelatedSearchableKeys, eventSearchableKeys }) {
}); });
const updated = oldWsEvents.concat(newEvents); const updated = oldWsEvents.concat(newEvents);
jobSocketCounter.current = updated.length; jobSocketCounter.current = updated.length;
if (!oldWsEvents.length && min > remoteRowCount + 1) {
loadJobEvents(min);
}
return updated.sort((a, b) => a.counter - b.counter); return updated.sort((a, b) => a.counter - b.counter);
}); });
setCssMap((prevCssMap) => ({ setCssMap((prevCssMap) => ({
@@ -358,7 +361,7 @@ function JobOutput({ job, eventRelatedSearchableKeys, eventSearchableKeys }) {
} }
}; };
const loadJobEvents = async () => { const loadJobEvents = async (firstWsCounter = null) => {
const [params, loadRange] = getEventRequestParams(job, 50, [1, 50]); const [params, loadRange] = getEventRequestParams(job, 50, [1, 50]);
if (isMounted.current) { if (isMounted.current) {
@@ -371,6 +374,9 @@ function JobOutput({ job, eventRelatedSearchableKeys, eventSearchableKeys }) {
if (isFlatMode) { if (isFlatMode) {
params.not__stdout = ''; params.not__stdout = '';
} }
if (firstWsCounter) {
params.counter__lt = firstWsCounter;
}
const qsParams = parseQueryString(QS_CONFIG, location.search); const qsParams = parseQueryString(QS_CONFIG, location.search);
const eventPromise = getJobModel(job.type).readEvents(job.id, { const eventPromise = getJobModel(job.type).readEvents(job.id, {
...params, ...params,
@@ -435,7 +441,7 @@ function JobOutput({ job, eventRelatedSearchableKeys, eventSearchableKeys }) {
if (getEvent(counter)) { if (getEvent(counter)) {
return true; return true;
} }
if (index > remoteRowCount && index < remoteRowCount + wsEvents.length) { if (index >= remoteRowCount && index < remoteRowCount + wsEvents.length) {
return true; return true;
} }
return currentlyLoading.includes(counter); return currentlyLoading.includes(counter);
@@ -462,7 +468,7 @@ function JobOutput({ job, eventRelatedSearchableKeys, eventSearchableKeys }) {
} }
if ( if (
!event && !event &&
index > remoteRowCount && index >= remoteRowCount &&
index < remoteRowCount + wsEvents.length index < remoteRowCount + wsEvents.length
) { ) {
event = wsEvents[index - remoteRowCount]; event = wsEvents[index - remoteRowCount];