diff --git a/packages/components/src/api/tts/GetPendingTtsJobCount.ts b/packages/components/src/api/tts/GetPendingTtsJobCount.ts index c786adbe49..1fc361e09f 100644 --- a/packages/components/src/api/tts/GetPendingTtsJobCount.ts +++ b/packages/components/src/api/tts/GetPendingTtsJobCount.ts @@ -4,6 +4,7 @@ export interface GetPendingTtsJobCountSuccessResponse { success: boolean, pending_job_count: number, cache_time: Date, + refresh_interval_millis: number, } export interface GetPendingTtsJobCountErrorResponse { diff --git a/packages/fakeyou.com/src/v2/view/_common/SessionTtsInferenceResultsList.tsx b/packages/fakeyou.com/src/v2/view/_common/SessionTtsInferenceResultsList.tsx index ecb24aba73..af75736b81 100644 --- a/packages/fakeyou.com/src/v2/view/_common/SessionTtsInferenceResultsList.tsx +++ b/packages/fakeyou.com/src/v2/view/_common/SessionTtsInferenceResultsList.tsx @@ -28,12 +28,17 @@ interface Props { sessionSubscriptionsWrapper: SessionSubscriptionsWrapper; } +// TODO: This is duplicated in SessionTtsInferenceResultsList ! +// Default to querying every 15 seconds, but make it configurable serverside +const DEFAULT_QUEUE_REFRESH_INTERVAL_MILLIS = 15000; + function SessionTtsInferenceResultList(props: Props) { const [pendingTtsJobs, setPendingTtsJobs] = useState({ success: true, pending_job_count: 0, cache_time: new Date(0), // NB: Epoch is used for vector clock's initial state + refresh_interval_millis: DEFAULT_QUEUE_REFRESH_INTERVAL_MILLIS, }); useEffect(() => { @@ -47,7 +52,10 @@ function SessionTtsInferenceResultList(props: Props) { } } }; - const interval = setInterval(async () => fetch(), 15000); + // TODO: We're having an outage and need to lower this. + //const interval = setInterval(async () => fetch(), 15000); + const refreshInterval = Math.max(DEFAULT_QUEUE_REFRESH_INTERVAL_MILLIS, pendingTtsJobs.refresh_interval_millis); + const interval = setInterval(async () => fetch(), refreshInterval); fetch(); return () => clearInterval(interval); }, [pendingTtsJobs]); diff --git a/packages/fakeyou.com/src/v2/view/nav/TopNav.tsx b/packages/fakeyou.com/src/v2/view/nav/TopNav.tsx index b6c4eb4acd..add8aaa92e 100644 --- a/packages/fakeyou.com/src/v2/view/nav/TopNav.tsx +++ b/packages/fakeyou.com/src/v2/view/nav/TopNav.tsx @@ -41,6 +41,10 @@ import { Analytics } from "../../../common/Analytics"; import { faWaveformLines } from "@fortawesome/pro-solid-svg-icons"; import { faTvRetro } from "@fortawesome/pro-regular-svg-icons"; +// TODO: This is duplicated in SessionTtsInferenceResultsList ! +// Default to querying every 15 seconds, but make it configurable serverside +const DEFAULT_QUEUE_REFRESH_INTERVAL_MILLIS = 15000; + interface Props { sessionWrapper: SessionWrapper; logoutHandler: () => void; @@ -76,6 +80,7 @@ function TopNav(props: Props) { success: true, pending_job_count: 0, cache_time: new Date(0), // NB: Epoch is used for vector clock's initial state + refresh_interval_millis: DEFAULT_QUEUE_REFRESH_INTERVAL_MILLIS, }); useEffect(() => { @@ -91,7 +96,9 @@ function TopNav(props: Props) { }; // TODO: We're having an outage and need to lower this. //const interval = setInterval(async () => fetch(), 15000); - const interval = setInterval(async () => fetch(), 5 * 60 * 1000); + const refreshInterval = Math.max(DEFAULT_QUEUE_REFRESH_INTERVAL_MILLIS, pendingTtsJobs.refresh_interval_millis); + console.log('new interval', refreshInterval); + const interval = setInterval(async () => fetch(), refreshInterval); fetch(); return () => clearInterval(interval); }, [pendingTtsJobs]);