From 262a3a5849f6e82808d2faedbfdcad209e578bcb Mon Sep 17 00:00:00 2001 From: Evie Gauthier Date: Thu, 7 May 2026 22:19:37 -0400 Subject: [PATCH] chore: remove dead code, debug statements, and resolve TODOs - Delete ~95 lines of commented-out debug/test code in ASCIILexicalTable.ts - Remove console.warn(pronouns) debug statement in PerMessageProfileEditor.tsx - Replace silent .catch(() => {}) with .catch(console.warn) in ThreadDrawer.tsx - Add aria-label to icon-only delete chip in ImageTile.tsx - Replace unexplained 'as any' cast comment in RoomCallButton.tsx with MSC4075 context - Replace account data typing TODOs in AccountData.tsx and DevelopTools.tsx with explanatory comments --- .../components/image-pack-view/ImageTile.tsx | 1 + .../message/content/ImageContent.tsx | 6 +- src/app/features/room/MembersDrawer.tsx | 2 - src/app/features/room/RoomCallButton.tsx | 3 +- src/app/features/room/ThreadDrawer.tsx | 4 +- .../Persona/PerMessageProfileEditor.tsx | 2 - .../settings/developer-tools/AccountData.tsx | 4 +- .../settings/developer-tools/DevelopTools.tsx | 4 +- src/app/plugins/markdown/markdownToHtml.ts | 2 +- src/app/utils/ASCIILexicalTable.ts | 96 ------------------- 10 files changed, 13 insertions(+), 111 deletions(-) diff --git a/src/app/components/image-pack-view/ImageTile.tsx b/src/app/components/image-pack-view/ImageTile.tsx index 5692c7364..5645e7df5 100644 --- a/src/app/components/image-pack-view/ImageTile.tsx +++ b/src/app/components/image-pack-view/ImageTile.tsx @@ -72,6 +72,7 @@ export function ImageTile({ variant={deleted ? 'Critical' : 'Secondary'} fill="None" radii="Pill" + aria-label={deleted ? 'Undo deletion' : 'Mark for deletion'} onClick={() => onDeleteToggle?.(defaultShortcode)} > {deleted ? Undo : } diff --git a/src/app/components/message/content/ImageContent.tsx b/src/app/components/message/content/ImageContent.tsx index 13868c4bf..74ff98e37 100644 --- a/src/app/components/message/content/ImageContent.tsx +++ b/src/app/components/message/content/ImageContent.tsx @@ -144,7 +144,7 @@ export const ImageContent = as<'div', ImageContentProps>( useEffect(() => { if (!viewer) { setViewerFullSrc(null); - return; + return undefined; } if ( typeof matrixThumbnailMaxEdge !== 'number' || @@ -152,7 +152,7 @@ export const ImageContent = as<'div', ImageContentProps>( encInfo || url.startsWith('http') ) { - return; + return undefined; } let cancelled = false; void (async () => { @@ -200,7 +200,7 @@ export const ImageContent = as<'div', ImageContentProps>( : isContained ? { minHeight: containedReserveStrip ? toRem(stripMin) : undefined } : hasDimensions - ? { aspectRatio: `${info!.w} / ${info!.h}` } + ? { aspectRatio: `${info.w} / ${info.h}` } : { minHeight: '150px' }; const fillPreviewSlotStyle = fillsSlot diff --git a/src/app/features/room/MembersDrawer.tsx b/src/app/features/room/MembersDrawer.tsx index 2641899d4..3aeb18c15 100644 --- a/src/app/features/room/MembersDrawer.tsx +++ b/src/app/features/room/MembersDrawer.tsx @@ -296,8 +296,6 @@ export function MembersDrawer({ room, members }: MembersDrawerProps) { ); const handleMemberClick: MouseEventHandler = (evt) => { - // oxlint-disable-next-line no-console - console.log(evt); const btn = evt.currentTarget as HTMLButtonElement; const userId = btn.getAttribute('data-user-id'); if (!userId) return; diff --git a/src/app/features/room/RoomCallButton.tsx b/src/app/features/room/RoomCallButton.tsx index 3c60e5935..34b6c7545 100644 --- a/src/app/features/room/RoomCallButton.tsx +++ b/src/app/features/room/RoomCallButton.tsx @@ -25,7 +25,8 @@ export function RoomCallButton({ room }: RoomCallButtonProps) { startCall(room, { microphone, video, sound }); try { const now = Date.now(); - // TODO not use as any one day someday i swear + // org.matrix.msc4075.rtc.notification is not yet in the SDK's TimelineEvents union; + // cast to keyof TimelineEvents to satisfy sendEvent's overload until MSC4075 lands. await mx.sendEvent( room.roomId, 'org.matrix.msc4075.rtc.notification' as keyof TimelineEvents, diff --git a/src/app/features/room/ThreadDrawer.tsx b/src/app/features/room/ThreadDrawer.tsx index 070cdaf58..2d53f7c89 100644 --- a/src/app/features/room/ThreadDrawer.tsx +++ b/src/app/features/room/ThreadDrawer.tsx @@ -305,7 +305,7 @@ export function ThreadDrawer({ room, threadRootId, onClose, overlay }: ThreadDra if (room.getThread(threadRootId)) return; // created concurrently room.createThread(threadRootId, new MatrixEvent(rawEvt as IEvent), [], false); }) - .catch(() => {}); + .catch(console.warn); } } @@ -347,7 +347,7 @@ export function ThreadDrawer({ room, threadRootId, onClose, overlay }: ThreadDra mx.paginateEventTimeline(currThread.timelineSet.getLiveTimeline(), { backwards: true }) .then(() => forceUpdate((n) => n + 1)) - .catch(() => {}); + .catch(console.warn); // forceUpdateCounter must be in deps so this effect re-runs after // ThreadEvent.Update fires (which flips initialEventsFetched from false to // true). diff --git a/src/app/features/settings/Persona/PerMessageProfileEditor.tsx b/src/app/features/settings/Persona/PerMessageProfileEditor.tsx index f05129eae..ee1c77462 100644 --- a/src/app/features/settings/Persona/PerMessageProfileEditor.tsx +++ b/src/app/features/settings/Persona/PerMessageProfileEditor.tsx @@ -45,8 +45,6 @@ export function PerMessageProfileEditor({ const [currentId, setCurrentId] = useState(profileId); const [newId, setNewId] = useState(profileId); - console.warn(pronouns); - // Pronouns const [currentPronouns, setCurrentPronouns] = useState(pronouns); const [newPronouns, setNewPronouns] = useState(pronouns); diff --git a/src/app/features/settings/developer-tools/AccountData.tsx b/src/app/features/settings/developer-tools/AccountData.tsx index da2169189..726a078a5 100644 --- a/src/app/features/settings/developer-tools/AccountData.tsx +++ b/src/app/features/settings/developer-tools/AccountData.tsx @@ -15,14 +15,14 @@ type AccountDataProps = { export function AccountData({ expand, onExpandToggle, onSelect }: AccountDataProps) { const mx = useMatrixClient(); const [accountDataTypes, setAccountDataKeys] = useState(() => - // TODO: tighten this once account data event typing is standardized. + // Account data keys are arbitrary strings (any MSC or custom event); no further narrowing needed. Array.from(mx.store.accountData.keys()) ); useAccountDataCallback( mx, useCallback(() => { - // TODO: tighten this once account data event typing is standardized. + // Account data keys are arbitrary strings (any MSC or custom event); no further narrowing needed. setAccountDataKeys(Array.from(mx.store.accountData.keys())); }, [mx]) ); diff --git a/src/app/features/settings/developer-tools/DevelopTools.tsx b/src/app/features/settings/developer-tools/DevelopTools.tsx index 100119726..4dfba7d16 100644 --- a/src/app/features/settings/developer-tools/DevelopTools.tsx +++ b/src/app/features/settings/developer-tools/DevelopTools.tsx @@ -28,7 +28,7 @@ export function DeveloperTools({ requestBack, requestClose }: DeveloperToolsProp const submitAccountData: AccountDataSubmitCallback = useCallback( async (type, content) => { - // TODO: remove cast once account data typing is unified. + // as never: developer tools submit arbitrary account data types beyond the typed enum. await mx.setAccountData(type as never, content as never); }, [mx] @@ -40,7 +40,7 @@ export function DeveloperTools({ requestBack, requestClose }: DeveloperToolsProp type={accountDataType ?? undefined} content={ accountDataType - ? // TODO: remove cast once account data typing is unified. + ? // as never: developer tools read arbitrary account data types beyond the typed enum. mx.getAccountData(accountDataType as never)?.getContent() : undefined } diff --git a/src/app/plugins/markdown/markdownToHtml.ts b/src/app/plugins/markdown/markdownToHtml.ts index 8bdc41200..58e3439e9 100644 --- a/src/app/plugins/markdown/markdownToHtml.ts +++ b/src/app/plugins/markdown/markdownToHtml.ts @@ -77,7 +77,7 @@ const shieldBareMatrixToLinks = ( const unshieldBareMatrixToLinks = (html: string, placeholders: Map): string => { let result = html; - const keys = [...placeholders.keys()].sort((a, b) => b.length - a.length); + const keys = [...placeholders.keys()].toSorted((a, b) => b.length - a.length); for (const key of keys) { const url = placeholders.get(key); if (url) result = result.split(key).join(escapeHtml(url)); diff --git a/src/app/utils/ASCIILexicalTable.ts b/src/app/utils/ASCIILexicalTable.ts index 93124f160..b302e262e 100644 --- a/src/app/utils/ASCIILexicalTable.ts +++ b/src/app/utils/ASCIILexicalTable.ts @@ -239,102 +239,6 @@ export class ASCIILexicalTable { } } -// const printLex = (lex: ASCIILexicalTable) => { -// const padRight = (s: string, maxWidth: number, padding: string): string => { -// let ns = s; -// for (let i = s.length; i < maxWidth; i += 1) { -// ns += padding; -// } -// return ns; -// }; - -// const formattedLine = (n: number, item: string): string => -// `|${padRight(n.toString(), lex.size().toString().length, ' ')}|${item}|`; - -// const hr = `|${padRight('-', lex.size().toString().length, '-')}|${padRight( -// '-', -// lex.maxStrWidth, -// '-' -// )}|`; - -// console.log(`All lexicographic string combination in order.`); -// console.log(`Start ASCII code: "${lex.startCode}"`); -// console.log(`End ASCII code: "${lex.endCode}"`); -// console.log(`Max string width: ${lex.maxStrWidth}`); -// console.log(`Total String Combination Count: ${lex.size()}\n`); -// console.log('Table:'); -// console.log(hr); -// for (let i = 0; i < lex.size(); i += 1) { -// const str = lex.get(i); -// if (str) { -// console.log(formattedLine(i, padRight(str, lex.maxStrWidth, '_'))); -// } -// } -// console.log(hr); -// }; - -// console.log('\n'); - -// const lex = new ASCIILexicalTable('a'.charCodeAt(0), 'c'.charCodeAt(0), 3); -// printLex(lex); -// console.log(lex.size()); -// console.log(lex.nBetween(8, ' ', '~~~~~')); -// console.log(lex.between('a', 'ccc')); -// console.log(lex.get(11)); -// console.log(lex.get(11) === 'aaac'); - -// const lex4 = new ASCIILexicalTable(' '.charCodeAt(0), '~'.charCodeAt(0), 5); -// console.log('Size: ', lex4.size()); -// console.log('Between: ', lex4.between('7g7g5', 'caccc')); -// printLex(lex4); - -// console.log('\n'); - -// const perf = () => { -// const loopLength = 99999; -// const lexT = new ASCIILexicalTable('a'.charCodeAt(0), 'z'.charCodeAt(0), 9); -// console.log(lexT.size()); -// const str = 'bcbba'; -// const strI = lexT.index(str); -// console.log('================'); -// console.time('index'); -// console.log(lexT.index(str)); -// for (let i = 0; i < loopLength; i += 1) { -// lexT.index(str); -// } -// console.timeEnd('index'); -// console.log('================'); -// console.time('get'); -// console.log(lexT.get(strI)); -// for (let i = 0; i < loopLength; i += 1) { -// lexT.get(strI); -// } -// console.timeEnd('get'); -// console.log('================'); -// console.time('previous'); -// console.log(lexT.previous(str)); -// for (let i = 0; i < loopLength; i += 1) { -// lexT.previous(str); -// } -// console.timeEnd('previous'); -// console.log('================'); -// console.time('next'); -// console.log(lexT.next(str)); -// for (let i = 0; i < loopLength; i += 1) { -// lexT.next(str); -// } -// console.timeEnd('next'); -// console.log('================'); -// console.time('between'); -// console.log(lexT.between(str, 'cbbca')); -// for (let i = 0; i < loopLength; i += 1) { -// lexT.between(str, 'cbbca'); -// } -// console.timeEnd('between'); -// }; - -// perf(); - const findNextFilledKey = ( fromIndex: number, keys: Array