18972: Records the last refresh click on localStorage for others to act on.
[arvados-workbench2.git] / src / views-components / auto-logout / auto-logout.tsx
index 65885627b348992dca234ba2206b7de6e8b3c418..a2d71d08dc406bf2d1baf96d13ce2929f5291c28 100644 (file)
@@ -10,7 +10,7 @@ import { RootState } from "store/store";
 import { SnackbarKind, snackbarActions } from "store/snackbar/snackbar-actions";
 import { logout } from "store/auth/auth-action";
 import parse from "parse-duration";
-import * as React from "react";
+import React from "react";
 import { min } from "lodash";
 
 interface AutoLogoutDataProps {
@@ -40,7 +40,7 @@ const mapDispatchToProps = (dispatch: Dispatch): AutoLogoutActionProps => ({
 export type AutoLogoutProps = AutoLogoutDataProps & AutoLogoutActionProps;
 
 const debounce = (delay: number | undefined, fn: Function) => {
-    let timerId: number | null;
+    let timerId: NodeJS.Timer | null;
     return (...args: any[]) => {
         if (timerId) { clearTimeout(timerId); }
         timerId = setTimeout(() => {
@@ -63,7 +63,7 @@ export const AutoLogoutComponent = (props: AutoLogoutProps) => {
         return () => {
             window.removeEventListener('storage', handleStorageEvents);
         };
-    }, []);
+    });
 
     const handleStorageEvents = (e: StorageEvent) => {
         if (e.key === LAST_ACTIVE_TIMESTAMP) {
@@ -90,7 +90,7 @@ export const AutoLogoutComponent = (props: AutoLogoutProps) => {
 
     const handleOnAction = () => {
         // Notify the other tabs there was some activity.
-        const now = (new Date).getTime();
+        const now = (new Date()).getTime();
         localStorage.setItem(LAST_ACTIVE_TIMESTAMP, now.toString());
     };