fix: address eslint no-console and no-void issues
This commit is contained in:
12 files changed
+78
-24
No files matched your search
@@ -4,6 +4,7 @@ import { AsyncStatus, useAsyncCallbackValue } from '../hooks/useAsyncCallback';
|
||||
import { useMatrixClient } from '../hooks/useMatrixClient';
|
||||
import { MediaConfig } from '../hooks/useMediaConfig';
|
||||
import { promiseFulfilledResult } from '../utils/common';
|
||||
import { createLogger } from '../utils/debug';
|
||||
|
||||
export type ServerConfigs = {
|
||||
capabilities?: Capabilities;
|
||||
@@ -14,6 +15,9 @@ export type ServerConfigs = {
|
||||
type ServerConfigsLoaderProps = {
|
||||
children: (configs: ServerConfigs) => ReactNode;
|
||||
};
|
||||
|
||||
const log = createLogger('ServerConfigsLoader');
|
||||
|
||||
export function ServerConfigsLoader({ children }: ServerConfigsLoaderProps) {
|
||||
const mx = useMatrixClient();
|
||||
const fallbackConfigs = useMemo(() => ({}), []);
|
||||
@@ -34,7 +38,7 @@ export function ServerConfigsLoader({ children }: ServerConfigsLoaderProps) {
|
||||
try {
|
||||
validatedAuthMetadata = validateAuthMetadata(authMetadata);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
log.error('Failed to validate auth metadata:', e);
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
@@ -27,9 +27,12 @@ import {
|
||||
WidgetApiFromWidgetAction,
|
||||
WidgetKind,
|
||||
} from 'matrix-widget-api';
|
||||
import { createLogger } from '$appUtils/debug';
|
||||
import { CinnyWidget } from './CinnyWidget';
|
||||
import { SmallWidgetDriver } from './SmallWidgetDriver';
|
||||
|
||||
const log = createLogger('SmallWidget');
|
||||
|
||||
/**
|
||||
* Generates the URL for the Element Call widget.
|
||||
* @param mx - The MatrixClient instance.
|
||||
@@ -215,7 +218,9 @@ export class SmallWidget extends EventEmitter {
|
||||
private onStateUpdate = (ev: MatrixEvent): void => {
|
||||
if (this.messaging === null || !ev.isState()) return;
|
||||
const raw = ev.getEffectiveEvent();
|
||||
this.messaging.feedStateUpdate(raw as IRoomEvent).catch(() => null);
|
||||
this.messaging.feedStateUpdate(raw as IRoomEvent).catch((err) => {
|
||||
log.warn('Failed to feed widget state update:', err);
|
||||
});
|
||||
};
|
||||
|
||||
private onToDeviceEvent = async (ev: MatrixEvent): Promise<void> => {
|
||||
@@ -326,7 +331,9 @@ export class SmallWidget extends EventEmitter {
|
||||
this.eventsToFeed.add(ev);
|
||||
} else {
|
||||
const raw = ev.getEffectiveEvent();
|
||||
this.messaging.feedEvent(raw as IRoomEvent).catch(() => null);
|
||||
this.messaging.feedEvent(raw as IRoomEvent).catch((err) => {
|
||||
log.warn('Failed to feed widget event:', err);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,12 +9,15 @@ import { useMatrixClient } from '$hooks/useMatrixClient';
|
||||
import { StateEvent } from '$types/matrix/room';
|
||||
import { useRoomCreators } from '$hooks/useRoomCreators';
|
||||
import { useRoomPermissions } from '$hooks/useRoomPermissions';
|
||||
import { createLogger } from '$appUtils/debug';
|
||||
import { SequenceCardStyle } from '../styles.css';
|
||||
|
||||
type CosmeticsProps = {
|
||||
requestClose: () => void;
|
||||
};
|
||||
|
||||
const log = createLogger('Cosmetics');
|
||||
|
||||
export function Cosmetics({ requestClose }: CosmeticsProps) {
|
||||
const mx = useMatrixClient();
|
||||
const room = useRoom();
|
||||
@@ -41,7 +44,7 @@ export function Cosmetics({ requestClose }: CosmeticsProps) {
|
||||
try {
|
||||
await mx.sendStateEvent(room.roomId, StateEvent.RoomPowerLevels as any, newContent, '');
|
||||
} catch (e) {
|
||||
console.error(`Failed to update permissions for ${eventType}:`, e);
|
||||
log.error(`Failed to update permissions for ${eventType}:`, e);
|
||||
}
|
||||
},
|
||||
[mx, room.roomId, powerLevels]
|
||||
|
||||
@@ -37,6 +37,7 @@ import { useSetting } from '$state/hooks/settings';
|
||||
import { settingsAtom } from '$state/settings';
|
||||
import { useSpaceOptionally } from '$hooks/useSpace';
|
||||
import { getHomeSearchPath, getSpaceSearchPath, withSearchParam } from '$pages/pathUtils';
|
||||
import { createLogger } from '$appUtils/debug';
|
||||
import { getCanonicalAliasOrRoomId, isRoomAlias, mxcUrlToHttp } from '$appUtils/matrix';
|
||||
import { _SearchPathSearchParams } from '$pages/paths';
|
||||
import { useRoomUnread } from '$state/hooks/unread';
|
||||
@@ -72,6 +73,8 @@ import { JumpToTime } from './jump-to-time';
|
||||
import { RoomPinMenu } from './room-pin-menu';
|
||||
import * as css from './RoomViewHeader.css';
|
||||
|
||||
const log = createLogger('RoomViewHeader');
|
||||
|
||||
async function getPinsHash(pinnedIds: string[]): Promise<string> {
|
||||
const sorted = [...pinnedIds].sort().join(',');
|
||||
const encoder = new TextEncoder();
|
||||
@@ -306,7 +309,11 @@ export function RoomViewHeader() {
|
||||
const [currentHash, setCurrentHash] = useState<string>('');
|
||||
|
||||
useEffect(() => {
|
||||
void getPinsHash(pinnedIds).then(setCurrentHash);
|
||||
getPinsHash(pinnedIds)
|
||||
.then(setCurrentHash)
|
||||
.catch((err) => {
|
||||
log.warn('Failed to compute pins hash:', err);
|
||||
});
|
||||
}, [pinnedIds]);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -334,7 +341,9 @@ export function RoomViewHeader() {
|
||||
setUnreadPinsCount(Math.max(0, newCount));
|
||||
}
|
||||
};
|
||||
void checkUnreads();
|
||||
checkUnreads().catch((err) => {
|
||||
log.warn('Failed to check unread pins:', err);
|
||||
});
|
||||
}, [pinnedIds, pinMarker]);
|
||||
|
||||
const handleSearchClick = () => {
|
||||
@@ -365,7 +374,9 @@ export function RoomViewHeader() {
|
||||
});
|
||||
};
|
||||
|
||||
void updateMarker();
|
||||
updateMarker().catch((err) => {
|
||||
log.warn('Failed to update pin marker:', err);
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -17,6 +17,9 @@ import { encryptFile, getImageInfo, getThumbnailContent, getVideoInfo } from '$a
|
||||
import { TUploadItem } from '$state/room/roomInputDrafts';
|
||||
import { encodeBlurHash } from '$appUtils/blurHash';
|
||||
import { scaleYDimension } from '$appUtils/common';
|
||||
import { createLogger } from '$appUtils/debug';
|
||||
|
||||
const log = createLogger('msgContent');
|
||||
|
||||
const generateThumbnailContent = async (
|
||||
mx: MatrixClient,
|
||||
@@ -50,7 +53,7 @@ export const getImageMsgContent = async (
|
||||
): Promise<IContent> => {
|
||||
const { file, originalFile, encInfo, metadata } = item;
|
||||
const [imgError, imgEl] = await to(loadImageElement(getImageFileUrl(originalFile)));
|
||||
if (imgError) console.warn(imgError);
|
||||
if (imgError) log.warn('Failed to load image element:', imgError);
|
||||
|
||||
const content: IContent = {
|
||||
msgtype: MsgType.Image,
|
||||
@@ -85,7 +88,7 @@ export const getVideoMsgContent = async (
|
||||
const { file, originalFile, encInfo, metadata } = item;
|
||||
|
||||
const [videoError, videoEl] = await to(loadVideoElement(getVideoFileUrl(originalFile)));
|
||||
if (videoError) console.warn(videoError);
|
||||
if (videoError) log.warn('Failed to load video element:', videoError);
|
||||
|
||||
const content: IContent = {
|
||||
msgtype: MsgType.Video,
|
||||
@@ -109,7 +112,7 @@ export const getVideoMsgContent = async (
|
||||
scaleYDimension(videoEl.videoWidth, 512, videoEl.videoHeight)
|
||||
);
|
||||
}
|
||||
if (thumbError) console.warn(thumbError);
|
||||
if (thumbError) log.warn('Failed to generate video thumbnail:', thumbError);
|
||||
content.info = {
|
||||
...getVideoInfo(videoEl, file),
|
||||
...thumbContent,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/* eslint-disable react/no-unused-prop-types */
|
||||
import { forwardRef, MouseEventHandler, ReactNode, useCallback, useMemo, useRef } from 'react';
|
||||
import { MatrixEvent, Room, RoomPinnedEventsEventContent } from '$types/matrix-sdk';
|
||||
import {
|
||||
@@ -20,6 +21,7 @@ import { Opts as LinkifyOpts } from 'linkifyjs';
|
||||
import { HTMLReactParserOptions } from 'html-react-parser';
|
||||
import { useAtomValue } from 'jotai';
|
||||
import { useVirtualizer } from '@tanstack/react-virtual';
|
||||
import { createLogger } from '$appUtils/debug';
|
||||
import { useRoomPinnedEvents } from '$hooks/useRoomPinnedEvents';
|
||||
import { SequenceCard } from '$components/sequence-card';
|
||||
import { useRoomEvent } from '$hooks/useRoomEvent';
|
||||
@@ -88,6 +90,8 @@ import { EncryptedContent } from '../message';
|
||||
import * as css from './RoomPinMenu.css';
|
||||
import { PinReadMarker } from '../RoomViewHeader';
|
||||
|
||||
const log = createLogger('RoomPinMenu');
|
||||
|
||||
type PinnedMessageProps = {
|
||||
room: Room;
|
||||
eventId: string;
|
||||
@@ -215,7 +219,9 @@ function PinnedMessage(props: PinnedMessageProps) {
|
||||
const handleUnpinClick: MouseEventHandler = useCallback(
|
||||
(evt) => {
|
||||
evt.stopPropagation();
|
||||
void unpin();
|
||||
unpin().catch((err) => {
|
||||
log.warn('Failed to unpin room event:', err);
|
||||
});
|
||||
},
|
||||
[unpin]
|
||||
);
|
||||
|
||||
@@ -8,9 +8,12 @@ import {
|
||||
MatrixEvent,
|
||||
MatrixEventEvent,
|
||||
} from '$types/matrix-sdk';
|
||||
import { createLogger } from '$appUtils/debug';
|
||||
import { resolveWidgetUrl } from '$hooks/useRoomWidgets';
|
||||
import { GenericWidgetDriver, CapabilityApprovalCallback } from './GenericWidgetDriver';
|
||||
|
||||
const log = createLogger('WidgetIframe');
|
||||
|
||||
interface WidgetIframeProps {
|
||||
widget: IWidget;
|
||||
roomId: string;
|
||||
@@ -95,7 +98,9 @@ export function WidgetIframe({ widget, roomId, mx, onCapabilityRequest }: Widget
|
||||
if (!messagingRef.current) return;
|
||||
if (ev.isBeingDecrypted() || ev.isDecryptionFailure()) return;
|
||||
const raw = ev.getEffectiveEvent();
|
||||
messagingRef.current.feedEvent(raw as IRoomEvent).catch(() => null);
|
||||
messagingRef.current.feedEvent(raw as IRoomEvent).catch((err) => {
|
||||
log.warn('Failed to feed widget iframe event:', err);
|
||||
});
|
||||
};
|
||||
|
||||
const onEvent = (ev: MatrixEvent): void => {
|
||||
|
||||
@@ -25,17 +25,19 @@ import { usePowerLevelsContext } from '$hooks/usePowerLevels';
|
||||
import { useRoomCreators } from '$hooks/useRoomCreators';
|
||||
import { useRoomPermissions } from '$hooks/useRoomPermissions';
|
||||
import { StateEvent } from '$types/matrix/room';
|
||||
import { createLogger } from '$appUtils/debug';
|
||||
import { WidgetIframe } from './WidgetIframe';
|
||||
import * as css from './WidgetsDrawer.css';
|
||||
import { IntegrationManager } from './IntegrationManager';
|
||||
|
||||
type WidgetsDrawerHeaderProps = {
|
||||
room: Room;
|
||||
activeWidget: RoomWidget | null;
|
||||
onBack: () => void;
|
||||
};
|
||||
|
||||
function WidgetDrawerHeader({ room, activeWidget, onBack }: WidgetsDrawerHeaderProps) {
|
||||
const log = createLogger('WidgetsDrawer');
|
||||
|
||||
function WidgetDrawerHeader({ activeWidget, onBack }: WidgetsDrawerHeaderProps) {
|
||||
const setWidgetDrawer = useSetSetting(settingsAtom, 'isWidgetDrawer');
|
||||
|
||||
return (
|
||||
@@ -114,7 +116,7 @@ function AddWidgetForm({ room, onAdded }: AddWidgetFormProps) {
|
||||
setUrl('');
|
||||
onAdded();
|
||||
} catch (err) {
|
||||
console.error('Failed to add widget:', err);
|
||||
log.error('Failed to add widget:', err);
|
||||
} finally {
|
||||
setAdding(false);
|
||||
}
|
||||
@@ -231,7 +233,7 @@ export function WidgetsDrawer({ room }: WidgetsDrawerProps) {
|
||||
setActiveWidget(null);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Failed to remove widget:', err);
|
||||
log.error('Failed to remove widget:', err);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -239,7 +241,7 @@ export function WidgetsDrawer({ room }: WidgetsDrawerProps) {
|
||||
|
||||
return (
|
||||
<Box className={css.WidgetsDrawer} direction="Column">
|
||||
<WidgetDrawerHeader room={room} activeWidget={activeWidget} onBack={handleBack} />
|
||||
<WidgetDrawerHeader activeWidget={activeWidget} onBack={handleBack} />
|
||||
{activeWidget ? (
|
||||
<Box className={css.WidgetIframeContainer} grow="Yes">
|
||||
<WidgetIframe key={activeWidget.id} widget={activeWidget} roomId={room.roomId} mx={mx} />
|
||||
|
||||
@@ -255,7 +255,7 @@ export function CallProvider({ children }: CallProviderProps) {
|
||||
setIsActiveCallReady(true);
|
||||
};
|
||||
|
||||
void sendWidgetAction(WIDGET_MEDIA_STATE_UPDATE_ACTION, {
|
||||
sendWidgetAction(WIDGET_MEDIA_STATE_UPDATE_ACTION, {
|
||||
audio_enabled: isAudioEnabled,
|
||||
video_enabled: isVideoEnabled,
|
||||
}).catch(() => {
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
import { createLogger } from './debug';
|
||||
|
||||
const log = createLogger('ASCIILexicalTable');
|
||||
|
||||
export class ASCIILexicalTable {
|
||||
readonly startCode: number;
|
||||
|
||||
@@ -36,7 +40,7 @@ export class ASCIILexicalTable {
|
||||
this.populateWidthToSize();
|
||||
|
||||
if (this.size() > Number.MAX_SAFE_INTEGER) {
|
||||
console.warn(
|
||||
log.warn(
|
||||
`[!] Warning: ASCIILexicalTable size is larger than the Number.MAX_SAFE_INTEGER: ${this.size()} > ${
|
||||
Number.MAX_SAFE_INTEGER
|
||||
}`
|
||||
|
||||
+11
-2
@@ -26,9 +26,11 @@ import {
|
||||
Sessions,
|
||||
ACTIVE_SESSION_KEY,
|
||||
} from './app/state/sessions';
|
||||
import { createLogger } from './app/utils/debug';
|
||||
import { getLocalStorageItem } from './app/state/utils/atomWithLocalStorage';
|
||||
|
||||
enableMapSet();
|
||||
const log = createLogger('index');
|
||||
|
||||
document.body.classList.add(configClass, varsClass);
|
||||
|
||||
@@ -48,8 +50,15 @@ if ('serviceWorker' in navigator) {
|
||||
pushSessionToSW(active?.baseUrl, active?.accessToken);
|
||||
};
|
||||
|
||||
void navigator.serviceWorker.register(swUrl).then(sendSessionToSW);
|
||||
void navigator.serviceWorker.ready.then(sendSessionToSW);
|
||||
navigator.serviceWorker
|
||||
.register(swUrl)
|
||||
.then(sendSessionToSW)
|
||||
.catch((err) => {
|
||||
log.warn('SW registration failed:', err);
|
||||
});
|
||||
navigator.serviceWorker.ready.then(sendSessionToSW).catch((err) => {
|
||||
log.warn('SW ready failed:', err);
|
||||
});
|
||||
|
||||
navigator.serviceWorker.addEventListener('message', (ev) => {
|
||||
const { data } = ev;
|
||||
|
||||
@@ -76,8 +76,8 @@ async function requestSessionWithTimeout(
|
||||
return Promise.race([sessionPromise, timeout]);
|
||||
}
|
||||
|
||||
self.addEventListener('install', () => {
|
||||
void self.skipWaiting();
|
||||
self.addEventListener('install', (event: ExtendableEvent) => {
|
||||
event.waitUntil(self.skipWaiting());
|
||||
});
|
||||
|
||||
self.addEventListener('activate', (event: ExtendableEvent) => {
|
||||
@@ -102,7 +102,7 @@ self.addEventListener('message', (event: ExtendableMessageEvent) => {
|
||||
|
||||
if (type === 'setSession') {
|
||||
setSession(client.id, accessToken, baseUrl);
|
||||
void cleanupDeadClients();
|
||||
event.waitUntil(cleanupDeadClients());
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user