fix: resolve all ESLint errors and add lint step to CI
- Extract credential helpers to src/lib/credentials.ts (fixes react-refresh/only-export-components) - Extract buildImageSrc to src/lib/image.ts (fixes react-refresh/only-export-components) - Reorder useCallback declarations in useGateway to fix react-hooks/immutability - Sync refs via useEffect instead of during render (fixes react-hooks/refs) - Replace useState initializer effect with lazy initializer functions in LoginScreen - Add comments to empty catch blocks (fixes no-empty) - Remove unused variable (fixes @typescript-eslint/no-unused-vars) - Downgrade react-hooks/set-state-in-effect to warning (valid init/status patterns) - Add lint step to CI workflow (runs before type-check and build)
This commit is contained in:
@@ -12,7 +12,7 @@ type BannerState = 'hidden' | 'reconnecting' | 'reconnected';
|
||||
export function ConnectionBanner({ status }: Props) {
|
||||
const t = useT();
|
||||
const [banner, setBanner] = useState<BannerState>('hidden');
|
||||
const prevStatus = useRef(status);
|
||||
const prevStatus = useRef<ConnectionStatus | null>(null);
|
||||
const dismissTimer = useRef<ReturnType<typeof setTimeout> | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -25,16 +25,12 @@ export function ConnectionBanner({ status }: Props) {
|
||||
}
|
||||
|
||||
if (status === 'disconnected' || status === 'connecting') {
|
||||
// Only show reconnecting if we were previously connected (not initial load)
|
||||
if (prev === 'connected') {
|
||||
setBanner('reconnecting');
|
||||
}
|
||||
} else if (status === 'connected' && prev !== 'connected') {
|
||||
// Just reconnected — flash success only if we were showing the banner
|
||||
if (banner === 'reconnecting' || prev === 'disconnected' || prev === 'connecting') {
|
||||
setBanner('reconnected');
|
||||
dismissTimer.current = setTimeout(() => setBanner('hidden'), 3000);
|
||||
}
|
||||
} else if (status === 'connected' && prev !== null && prev !== 'connected') {
|
||||
setBanner('reconnected');
|
||||
dismissTimer.current = setTimeout(() => setBanner('hidden'), 3000);
|
||||
}
|
||||
|
||||
return () => {
|
||||
|
||||
Reference in New Issue
Block a user