diff --git a/client/src/components/History/providers/HistoryContentProvider/loadContents.js b/client/src/components/History/providers/HistoryContentProvider/loadContents.js index 8a57785f2e8..43e99a457f2 100644 --- a/client/src/components/History/providers/HistoryContentProvider/loadContents.js +++ b/client/src/components/History/providers/HistoryContentProvider/loadContents.js @@ -6,30 +6,30 @@ import { loadHistoryContents } from "../../caching"; // prettier-ignore export const loadContents = (cfg = {}) => { - const { - windowSize, - initialInterval = 3 * 1000, - maxInterval = 10 * initialInterval, - disablePoll = false, + const { + windowSize, + initialInterval = 2 * 1000, + maxInterval = 10 * initialInterval, + disablePoll = false } = cfg; - return switchMap(([{id}, params, hid]) => { + return switchMap(([{ id }, params, hid]) => { // a single history update - const singleLoad$ = defer(() => of([id, params, hid]).pipe( - loadHistoryContents({ windowSize }), - )); + const singleLoad$ = of([id, params, hid]).pipe( + loadHistoryContents({ windowSize }) + ); // start repeating, delay gets longer over time until unsubscribed - const freshPoll$ = singleLoad$.pipe( + const freshPoll$ = defer(() => singleLoad$.pipe( decay({ initialInterval, maxInterval }), - repeat(), - ); + repeat() + )); // history, tools routes all refresh // exclude our own polling url though const routes = [/api\/(history|tools|histories)/]; - const methods = ["POST", "PUT", "DELETE"] + const methods = ["POST", "PUT", "DELETE"]; const resetPoll$ = monitorXHR({ methods, routes }); // resets re-subscribe to freshPoll$ starting the decay over again @@ -40,5 +40,5 @@ export const loadContents = (cfg = {}) => { ); return disablePoll ? singleLoad$ : poll$; - }) -} + }); +}; diff --git a/client/src/utils/observable/decay.js b/client/src/utils/observable/decay.js index 1c3b702da7c..b1ec4a94802 100644 --- a/client/src/utils/observable/decay.js +++ b/client/src/utils/observable/decay.js @@ -2,6 +2,8 @@ import { of } from "rxjs"; import { mergeMap, delay } from "rxjs/operators"; +let decayCounter = 0; + // prettier-ignore export const decay = (cfg = {}) => { const { @@ -15,12 +17,13 @@ export const decay = (cfg = {}) => { } let counter = 0; + decayCounter++; return mergeMap(val => { let waitTime = Math.floor(initialInterval * Math.exp(lambda * counter++)); waitTime = Math.max(waitTime, initialInterval); waitTime = Math.min(waitTime, maxInterval); - // console.log("decay time", waitTime); + console.log("decay time", decayCounter, waitTime); return of(val).pipe(delay(waitTime)) }); }