feat(chat-window): lint & beautify

This commit is contained in:
ItzCrazyKns 2025-01-07 11:44:19 +05:30
parent 0ec54fe6c0
commit b7f7d25f54

View file

@ -73,7 +73,10 @@ const useSocket = (
}, },
}, },
).then(async (res) => { ).then(async (res) => {
if (!res.ok) throw new Error(`Failed to fetch models: ${res.status} ${res.statusText}`); if (!res.ok)
throw new Error(
`Failed to fetch models: ${res.status} ${res.statusText}`,
);
return res.json(); return res.json();
}); });
@ -262,7 +265,6 @@ const useSocket = (
attemptReconnect(); attemptReconnect();
} }
}; };
} catch (error) { } catch (error) {
console.debug(new Date(), 'ws:error', error); console.debug(new Date(), 'ws:error', error);
attemptReconnect(); attemptReconnect();
@ -274,12 +276,17 @@ const useSocket = (
if (retryCountRef.current > MAX_RETRIES) { if (retryCountRef.current > MAX_RETRIES) {
console.debug(new Date(), 'ws:max_retries'); console.debug(new Date(), 'ws:max_retries');
setError(true); setError(true);
toast.error('Unable to connect to server after multiple attempts. Please refresh the page to try again.'); toast.error(
'Unable to connect to server after multiple attempts. Please refresh the page to try again.',
);
return; return;
} }
const backoffDelay = getBackoffDelay(retryCountRef.current); const backoffDelay = getBackoffDelay(retryCountRef.current);
console.debug(new Date(), `ws:retry attempt=${retryCountRef.current}/${MAX_RETRIES} delay=${backoffDelay}ms`); console.debug(
new Date(),
`ws:retry attempt=${retryCountRef.current}/${MAX_RETRIES} delay=${backoffDelay}ms`,
);
if (reconnectTimeoutRef.current) { if (reconnectTimeoutRef.current) {
clearTimeout(reconnectTimeoutRef.current); clearTimeout(reconnectTimeoutRef.current);