fix addtional things

This commit is contained in:
Nate Kelley 2025-05-28 22:08:21 -06:00
parent 64f7d1ccd4
commit 4fb36a8d60
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
2 changed files with 14 additions and 9 deletions

View File

@ -56,7 +56,7 @@ async function detectDeviceCapabilities(): Promise<DeviceCapabilities> {
const cores = navigator.hardwareConcurrency || 2;
// Check device memory (if available)
const memory = (navigator as any).deviceMemory || 4;
const memory = (navigator as Navigator & { deviceMemory: number }).deviceMemory || 4;
// Calculate device tier
if (
@ -65,11 +65,12 @@ async function detectDeviceCapabilities(): Promise<DeviceCapabilities> {
memory >= 4
) {
return DEVICE_TIERS.high;
} else if (performanceScore < 100 && cores >= 2 && memory >= 2) {
return DEVICE_TIERS.medium;
} else {
return DEVICE_TIERS.low;
}
if (performanceScore < 100 && cores >= 2 && memory >= 2) {
return DEVICE_TIERS.medium;
}
return DEVICE_TIERS.low;
} catch (error) {
console.warn('Error detecting device capabilities:', error);
return DEVICE_TIERS.medium; // Fallback to medium tier

View File

@ -47,6 +47,7 @@ const useBusterWebSocketHook = ({
}) => {
const { openErrorNotification } = useBusterNotifications();
// biome-ignore lint/suspicious/noExplicitAny: this truly can be anything
const onMessage = useMemoizedFn((responseMessage: BusterSocketResponseBase<string, any>) => {
try {
const { route, payload, error } = responseMessage;
@ -56,7 +57,7 @@ const useBusterWebSocketHook = ({
if (eventListeners.length > 0) {
requestAnimationFrame(() => {
const eventListeners = getCurrentListeners(route);
eventListeners.forEach(({ callback: cb, onError: onE }) => {
for (const { callback: cb, onError: onE } of eventListeners) {
if (error) {
if (onE) onE(error);
else openErrorNotification(error);
@ -68,7 +69,7 @@ const useBusterWebSocketHook = ({
openErrorNotification(callbackError);
}
}
});
}
});
}
} catch (error) {
@ -100,7 +101,7 @@ interface EventListeners {
}
const useBusterSocketListeners = (props: {
openErrorNotification: (d: any) => void;
openErrorNotification: (d: unknown) => void;
emit: (d: BusterSocketRequest) => void;
}) => {
const { emit, openErrorNotification } = props;
@ -122,12 +123,13 @@ const useBusterSocketListeners = (props: {
const once: BusterSocket['once'] = useMemoizedFn(({ route, callback }) => {
return new Promise((resolve, reject) => {
// biome-ignore lint/suspicious/noExplicitAny: this truly can be anything
const onceCallback = (payload: any) => {
callback(payload);
off({ route: route as '/chats/post:initializeChat', callback: onceCallback });
resolve(payload);
};
const onError = (error: any) => {
const onError = (error: unknown) => {
off({ route: route as '/chats/post:initializeChat', callback: onceCallback });
reject(error);
};
@ -147,10 +149,12 @@ const useBusterSocketListeners = (props: {
const { emitEvent, responseEvent } = params;
const { route, callback, onError } = responseEvent;
const promise = new Promise<Parameters<T['callback']>[0]>((resolve, reject) => {
// biome-ignore lint/suspicious/noExplicitAny: this truly can be anything
const promiseCallback = (d: any) => {
callback(d);
resolve(d);
};
// biome-ignore lint/suspicious/noExplicitAny: this truly can be anything
const onErrorCallback = (d: any) => {
if (!onError) openErrorNotification(d);
else onError?.(d);