Small bug fixes

This commit is contained in:
MrAlders0n
2026-05-29 23:13:18 -04:00
parent 96035aacb9
commit 185ee05028
3 changed files with 21 additions and 4 deletions
+5 -1
View File
@@ -24,6 +24,7 @@ export class WsManager {
private subscriptionId: string | null = null;
private status: WsStatus = "disconnected";
private reconnectAttempt = 0;
private intentionalClose = false;
private reconnectTimer: ReturnType<typeof setTimeout> | null = null;
private pingTimer: ReturnType<typeof setInterval> | null = null;
private msgCounter = 0;
@@ -111,6 +112,8 @@ export class WsManager {
}
disconnect(): void {
this.intentionalClose = true;
this.reconnectAttempt = 0;
this.clearTimers();
this.ws?.close();
this.ws = null;
@@ -120,6 +123,7 @@ export class WsManager {
// exponential backoff w/ jitter to avoid thundering herd on reconnect
private doConnect(): void {
this.intentionalClose = false;
this.clearTimers();
this.setStatus("connecting");
@@ -142,7 +146,7 @@ export class WsManager {
this.ws.onclose = (e: CloseEvent) => {
this.clearTimers();
if (e.code === 1000) {
if (this.intentionalClose || e.code === 1000) {
this.setStatus("disconnected");
return;
}
+10 -1
View File
@@ -1,4 +1,4 @@
import { useState, useRef, useCallback, type ReactNode } from "react";
import { useState, useRef, useCallback, useEffect, type ReactNode } from "react";
import { useClickOutside } from "../hooks/useClickOutside";
export function Dropdown({ renderTrigger, align = "right", width = "w-48", children }: {
@@ -13,6 +13,15 @@ export function Dropdown({ renderTrigger, align = "right", width = "w-48", child
const toggle = useCallback(() => setOpen((v) => !v), []);
useClickOutside(ref, open, close);
useEffect(() => {
if (!open) return;
function handleKey(e: KeyboardEvent) {
if (e.key === "Escape") close();
}
document.addEventListener("keydown", handleKey);
return () => document.removeEventListener("keydown", handleKey);
}, [open, close]);
return (
<div ref={ref} className="relative">
{renderTrigger({ open, toggle })}
+6 -2
View File
@@ -15,8 +15,12 @@ export function SplashScreen() {
// Synchronous gate: decided before first paint so StrictMode's double-mount
// (and any same-session reload) never re-shows it.
const [render, setRender] = useState(() => {
if (typeof sessionStorage === "undefined") return false;
return sessionStorage.getItem(SPLASH_KEY) !== "1";
try {
if (typeof sessionStorage === "undefined") return false;
return sessionStorage.getItem(SPLASH_KEY) !== "1";
} catch {
return false;
}
});
const [fading, setFading] = useState(false);