fix: remove timeout for deleting lastOnline store

Signed-off-by: Juan Escalada <juanescalada175@gmail.com>
This commit is contained in:
Juan Escalada
2026-05-13 11:41:40 +09:00
parent c3e07a5cb3
commit 327cc8b09c
2 changed files with 2 additions and 13 deletions
@@ -231,27 +231,15 @@ const parseConfig = (
export const AutoLogout = (props: AutoLogoutProps): JSX.Element | null => {
const identityApi = useApi(identityApiRef);
const configApi = useApi(configApiRef);
const isLoggedRef = useRef<boolean | null>(null);
const [isLogged, setIsLogged] = useState<boolean | null>(null);
const lastSeenOnlineStore: TimestampStore = useMemo(
() => new DefaultTimestampStore(LAST_SEEN_ONLINE_STORAGE_KEY),
[],
);
useEffect(() => {
isLoggedRef.current = isLogged;
}, [isLogged]);
useEffect(() => {
let cancelled = false;
const timeoutId = setTimeout(() => {
if (cancelled) return;
if (isLoggedRef.current === null || isLoggedRef.current === false) {
lastSeenOnlineStore.delete();
}
}, 3000);
async function checkLogin(identity: IdentityApi) {
try {
const creds = await identity.getCredentials();
@@ -272,7 +260,6 @@ export const AutoLogout = (props: AutoLogoutProps): JSX.Element | null => {
return () => {
cancelled = true;
clearTimeout(timeoutId);
};
}, [lastSeenOnlineStore, identityApi]);
@@ -48,6 +48,8 @@ describe('useLogoutDisconnectedUserEffect', () => {
renderHook(() => useLogoutDisconnectedUserEffect(props));
expect(mockTimestampStore.get).not.toHaveBeenCalled();
expect(mockTimestampStore.delete).not.toHaveBeenCalled();
expect(mockTimestampStore.save).not.toHaveBeenCalled();
expect(mockIdentityApi.signOut).not.toHaveBeenCalled();
});