notion 183: Home Page Refresh, keep it refreshing for 4 hours instead of 10 minutes

This commit is contained in:
burnettk 2023-03-28 13:41:58 -04:00
parent 141bb4fcb8
commit 2f0114bac3
4 changed files with 26 additions and 11 deletions

View File

@ -36,6 +36,8 @@ import {
getProcessModelFullIdentifierFromSearchParams,
modifyProcessIdentifierForPathParam,
refreshAtInterval,
REFRESH_INTERVAL_SECONDS,
REFRESH_TIMEOUT_SECONDS,
} from '../helpers';
import { useUriListForPermissions } from '../hooks/UriListForPermissions';
@ -68,9 +70,6 @@ import useAPIError from '../hooks/UseApiError';
import { usePermissionFetcher } from '../hooks/PermissionService';
import { Can } from '../contexts/Can';
const REFRESH_INTERVAL = 5;
const REFRESH_TIMEOUT = 600;
type OwnProps = {
filtersEnabled?: boolean;
processModelFullIdentifier?: string;
@ -389,8 +388,8 @@ export default function ProcessInstanceListTable({
checkFiltersAndRun();
if (autoReload) {
return refreshAtInterval(
REFRESH_INTERVAL,
REFRESH_TIMEOUT,
REFRESH_INTERVAL_SECONDS,
REFRESH_TIMEOUT_SECONDS,
checkFiltersAndRun
);
}

View File

@ -9,14 +9,14 @@ import {
getPageInfoFromSearchParams,
modifyProcessIdentifierForPathParam,
refreshAtInterval,
REFRESH_INTERVAL_SECONDS,
REFRESH_TIMEOUT_SECONDS,
} from '../helpers';
import HttpService from '../services/HttpService';
import { PaginationObject, ProcessInstanceTask } from '../interfaces';
import TableCellWithTimeAgoInWords from './TableCellWithTimeAgoInWords';
const PER_PAGE_FOR_TASKS_ON_HOME_PAGE = 5;
const REFRESH_INTERVAL = 5;
const REFRESH_TIMEOUT = 600;
type OwnProps = {
apiPath: string;
@ -89,7 +89,11 @@ export default function TaskListTable({
};
getTasks();
if (autoReload) {
return refreshAtInterval(REFRESH_INTERVAL, REFRESH_TIMEOUT, getTasks);
return refreshAtInterval(
REFRESH_INTERVAL_SECONDS,
REFRESH_TIMEOUT_SECONDS,
getTasks
);
}
return undefined;
}, [

View File

@ -270,3 +270,11 @@ export const encodeBase64 = (data: string) => {
export const decodeBase64 = (data: string) => {
return Buffer.from(data, 'base64').toString('ascii');
};
const MINUTES_IN_HOUR = 60;
const SECONDS_IN_MINUTE = 60;
const SECONDS_IN_HOUR = MINUTES_IN_HOUR * SECONDS_IN_MINUTE;
const FOUR_HOURS_IN_SECONDS = SECONDS_IN_HOUR * 4;
export const REFRESH_INTERVAL_SECONDS = 5;
export const REFRESH_TIMEOUT_SECONDS = FOUR_HOURS_IN_SECONDS;

View File

@ -8,6 +8,8 @@ import {
getPageInfoFromSearchParams,
modifyProcessIdentifierForPathParam,
refreshAtInterval,
REFRESH_INTERVAL_SECONDS,
REFRESH_TIMEOUT_SECONDS,
} from '../helpers';
import HttpService from '../services/HttpService';
import {
@ -19,8 +21,6 @@ import {
import ProcessInstanceRun from '../components/ProcessInstanceRun';
const PER_PAGE_FOR_TASKS_ON_HOME_PAGE = 5;
const REFRESH_INTERVAL = 5;
const REFRESH_TIMEOUT = 600;
export default function MyTasks() {
const [searchParams] = useSearchParams();
@ -46,7 +46,11 @@ export default function MyTasks() {
};
getTasks();
refreshAtInterval(REFRESH_INTERVAL, REFRESH_TIMEOUT, getTasks);
refreshAtInterval(
REFRESH_INTERVAL_SECONDS,
REFRESH_TIMEOUT_SECONDS,
getTasks
);
}, [searchParams]);
const processInstanceRunResultTag = () => {