Remove ts/services/timers.ts
This commit is contained in:
parent
26eabf16a8
commit
a537204fc0
10 changed files with 38 additions and 144 deletions
|
@ -7,18 +7,17 @@ import {
|
|||
} from '../state/ducks/network';
|
||||
import { getSocketStatus } from '../shims/socketStatus';
|
||||
import * as log from '../logging/log';
|
||||
import { SECOND } from '../util/durations';
|
||||
|
||||
type NetworkActions = {
|
||||
checkNetworkStatus: (x: CheckNetworkStatusPayloadType) => NetworkActionType;
|
||||
closeConnectingGracePeriod: () => NetworkActionType;
|
||||
};
|
||||
|
||||
const REFRESH_INTERVAL = 5000;
|
||||
|
||||
export function initializeNetworkObserver(
|
||||
networkActions: NetworkActions
|
||||
): void {
|
||||
log.info(`Initializing network observer every ${REFRESH_INTERVAL}ms`);
|
||||
log.info('Initializing network observer');
|
||||
|
||||
const refresh = () => {
|
||||
networkActions.checkNetworkStatus({
|
||||
|
@ -31,8 +30,7 @@ export function initializeNetworkObserver(
|
|||
|
||||
window.addEventListener('online', refresh);
|
||||
window.addEventListener('offline', refresh);
|
||||
window.setInterval(refresh, REFRESH_INTERVAL);
|
||||
window.setTimeout(() => {
|
||||
networkActions.closeConnectingGracePeriod();
|
||||
}, REFRESH_INTERVAL);
|
||||
}, 5 * SECOND);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue