chore: upgrade i18next 26, prettier 3, fontsource-variable, domhandler 6, lint-staged 17
CI / Build & Quality Checks (push) Successful in 10m13s
CI / Build & Quality Checks (push) Successful in 10m13s
- i18next 23->26 + react-i18next 15->17 - prettier 2->3, reformat all files - replace @fontsource/inter with @fontsource-variable/inter 5, update import path - domhandler 5->6 (aligns with transitive deps) - lint-staged 16->17
This commit is contained in:
@@ -141,7 +141,7 @@ const TimelineFloat = as<'div', css.TimelineFloatVariants>(
|
||||
{...props}
|
||||
ref={ref}
|
||||
/>
|
||||
)
|
||||
),
|
||||
);
|
||||
|
||||
const TimelineDivider = as<'div', { variant?: ContainerColor | 'Inherit' }>(
|
||||
@@ -151,7 +151,7 @@ const TimelineDivider = as<'div', { variant?: ContainerColor | 'Inherit' }>(
|
||||
{children}
|
||||
<Line style={{ flexGrow: 1 }} variant={variant} size="300" />
|
||||
</Box>
|
||||
)
|
||||
),
|
||||
);
|
||||
|
||||
export const getLiveTimeline = (room: Room): EventTimeline =>
|
||||
@@ -164,7 +164,7 @@ export const getEventTimeline = (room: Room, eventId: string): EventTimeline | u
|
||||
|
||||
export const getFirstLinkedTimeline = (
|
||||
timeline: EventTimeline,
|
||||
direction: Direction
|
||||
direction: Direction,
|
||||
): EventTimeline => {
|
||||
const linkedTm = timeline.getNeighbouringTimeline(direction);
|
||||
if (!linkedTm) return timeline;
|
||||
@@ -194,7 +194,7 @@ export const getTimelinesEventsCount = (timelines: EventTimeline[]): number => {
|
||||
|
||||
export const getTimelineAndBaseIndex = (
|
||||
timelines: EventTimeline[],
|
||||
index: number
|
||||
index: number,
|
||||
): [EventTimeline | undefined, number] => {
|
||||
let uptoTimelineLen = 0;
|
||||
const timeline = timelines.find((t) => {
|
||||
@@ -215,7 +215,7 @@ export const getTimelineEvent = (timeline: EventTimeline, index: number): Matrix
|
||||
export const getEventIdAbsoluteIndex = (
|
||||
timelines: EventTimeline[],
|
||||
eventTimeline: EventTimeline,
|
||||
eventId: string
|
||||
eventId: string,
|
||||
): number | undefined => {
|
||||
const timelineIndex = timelines.findIndex((t) => t === eventTimeline);
|
||||
if (timelineIndex === -1) return undefined;
|
||||
@@ -245,12 +245,12 @@ const useEventTimelineLoader = (
|
||||
mx: MatrixClient,
|
||||
room: Room,
|
||||
onLoad: (eventId: string, linkedTimelines: EventTimeline[], evtAbsIndex: number) => void,
|
||||
onError: (err: Error | null) => void
|
||||
onError: (err: Error | null) => void,
|
||||
) => {
|
||||
const loadEventTimeline = useCallback(
|
||||
async (eventId: string) => {
|
||||
const [err, replyEvtTimeline] = await to(
|
||||
mx.getEventTimeline(room.getUnfilteredTimelineSet(), eventId)
|
||||
mx.getEventTimeline(room.getUnfilteredTimelineSet(), eventId),
|
||||
);
|
||||
if (!replyEvtTimeline) {
|
||||
onError(err ?? null);
|
||||
@@ -266,7 +266,7 @@ const useEventTimelineLoader = (
|
||||
|
||||
onLoad(eventId, linkedTimelines, absIndex);
|
||||
},
|
||||
[mx, room, onLoad, onError]
|
||||
[mx, room, onLoad, onError],
|
||||
);
|
||||
|
||||
return loadEventTimeline;
|
||||
@@ -276,7 +276,7 @@ const useTimelinePagination = (
|
||||
mx: MatrixClient,
|
||||
timeline: Timeline,
|
||||
setTimeline: Dispatch<SetStateAction<Timeline>>,
|
||||
limit: number
|
||||
limit: number,
|
||||
) => {
|
||||
const timelineRef = useRef(timeline);
|
||||
timelineRef.current = timeline;
|
||||
@@ -288,7 +288,7 @@ const useTimelinePagination = (
|
||||
const recalibratePagination = (
|
||||
linkedTimelines: EventTimeline[],
|
||||
timelinesEventsCount: number[],
|
||||
backwards: boolean
|
||||
backwards: boolean,
|
||||
) => {
|
||||
const topTimeline = linkedTimelines[0];
|
||||
const timelineMatch = (mt: EventTimeline) => (t: EventTimeline) => t === mt;
|
||||
@@ -322,7 +322,7 @@ const useTimelinePagination = (
|
||||
if (!timelineToPaginate) return;
|
||||
|
||||
const paginationToken = timelineToPaginate.getPaginationToken(
|
||||
backwards ? Direction.Backward : Direction.Forward
|
||||
backwards ? Direction.Backward : Direction.Forward,
|
||||
);
|
||||
if (
|
||||
!paginationToken &&
|
||||
@@ -338,7 +338,7 @@ const useTimelinePagination = (
|
||||
mx.paginateEventTimeline(timelineToPaginate, {
|
||||
backwards,
|
||||
limit,
|
||||
})
|
||||
}),
|
||||
);
|
||||
if (err) {
|
||||
fetching = false;
|
||||
@@ -346,7 +346,7 @@ const useTimelinePagination = (
|
||||
}
|
||||
const fetchedTimeline =
|
||||
timelineToPaginate.getNeighbouringTimeline(
|
||||
backwards ? Direction.Backward : Direction.Forward
|
||||
backwards ? Direction.Backward : Direction.Forward,
|
||||
) ?? timelineToPaginate;
|
||||
// Decrypt all event ahead of render cycle
|
||||
const roomId = fetchedTimeline.getRoomId();
|
||||
@@ -372,7 +372,7 @@ const useLiveEventArrive = (room: Room, onArrive: (mEvent: MatrixEvent) => void)
|
||||
eventRoom,
|
||||
toStartOfTimeline,
|
||||
removed,
|
||||
data
|
||||
data,
|
||||
) => {
|
||||
if (eventRoom?.roomId !== room.roomId || !data.liveEvent) return;
|
||||
onArrive(mEvent);
|
||||
@@ -472,7 +472,7 @@ export function RoomTimeline({ room, eventId, roomInputRef, editor }: RoomTimeli
|
||||
const accessiblePowerTagColors = useAccessiblePowerTagColors(
|
||||
theme.kind,
|
||||
creatorsTag,
|
||||
powerLevelTags
|
||||
powerLevelTags,
|
||||
);
|
||||
|
||||
const permissions = useRoomPermissions(creators, powerLevels);
|
||||
@@ -524,10 +524,10 @@ export function RoomTimeline({ room, eventId, roomInputRef, editor }: RoomTimeli
|
||||
() => ({
|
||||
...LINKIFY_OPTS,
|
||||
render: factoryRenderLinkifyWithMention((href) =>
|
||||
renderMatrixMention(mx, room.roomId, href, makeMentionCustomProps(mentionClickHandler))
|
||||
renderMatrixMention(mx, room.roomId, href, makeMentionCustomProps(mentionClickHandler)),
|
||||
),
|
||||
}),
|
||||
[mx, room, mentionClickHandler]
|
||||
[mx, room, mentionClickHandler],
|
||||
);
|
||||
const htmlReactParserOptions = useMemo<HTMLReactParserOptions>(
|
||||
() =>
|
||||
@@ -537,12 +537,12 @@ export function RoomTimeline({ room, eventId, roomInputRef, editor }: RoomTimeli
|
||||
handleSpoilerClick: spoilerClickHandler,
|
||||
handleMentionClick: mentionClickHandler,
|
||||
}),
|
||||
[mx, room, linkifyOpts, spoilerClickHandler, mentionClickHandler, useAuthentication]
|
||||
[mx, room, linkifyOpts, spoilerClickHandler, mentionClickHandler, useAuthentication],
|
||||
);
|
||||
const parseMemberEvent = useMemberEventParser();
|
||||
|
||||
const [timeline, setTimeline] = useState<Timeline>(() =>
|
||||
eventId ? getEmptyTimeline() : getInitialTimeline(room)
|
||||
eventId ? getEmptyTimeline() : getInitialTimeline(room),
|
||||
);
|
||||
const timelineRef = React.useRef(timeline);
|
||||
timelineRef.current = timeline;
|
||||
@@ -571,7 +571,7 @@ export function RoomTimeline({ room, eventId, roomInputRef, editor }: RoomTimeli
|
||||
mx,
|
||||
timeline,
|
||||
setTimeline,
|
||||
PAGINATION_LIMIT
|
||||
PAGINATION_LIMIT,
|
||||
);
|
||||
|
||||
const getScrollElement = useCallback(() => scrollRef.current, []);
|
||||
@@ -587,7 +587,7 @@ export function RoomTimeline({ room, eventId, roomInputRef, editor }: RoomTimeli
|
||||
(index: number) =>
|
||||
(scrollRef.current?.querySelector(`[data-message-item="${index}"]`) as HTMLElement) ??
|
||||
undefined,
|
||||
[]
|
||||
[],
|
||||
),
|
||||
onEnd: handleTimelinePagination,
|
||||
});
|
||||
@@ -613,14 +613,14 @@ export function RoomTimeline({ room, eventId, roomInputRef, editor }: RoomTimeli
|
||||
},
|
||||
});
|
||||
},
|
||||
[alive]
|
||||
[alive],
|
||||
),
|
||||
useCallback(() => {
|
||||
if (!alive()) return;
|
||||
setTimeline(getInitialTimeline(room));
|
||||
scrollToBottomRef.current.count += 1;
|
||||
scrollToBottomRef.current.smooth = false;
|
||||
}, [alive, room])
|
||||
}, [alive, room]),
|
||||
);
|
||||
|
||||
useLiveEventArrive(
|
||||
@@ -661,15 +661,15 @@ export function RoomTimeline({ room, eventId, roomInputRef, editor }: RoomTimeli
|
||||
setUnreadInfo(getRoomUnreadInfo(room));
|
||||
}
|
||||
},
|
||||
[mx, room, unreadInfo, hideActivity]
|
||||
)
|
||||
[mx, room, unreadInfo, hideActivity],
|
||||
),
|
||||
);
|
||||
|
||||
const handleOpenEvent = useCallback(
|
||||
async (
|
||||
evtId: string,
|
||||
highlight = true,
|
||||
onScroll: ((scrolled: boolean) => void) | undefined = undefined
|
||||
onScroll: ((scrolled: boolean) => void) | undefined = undefined,
|
||||
) => {
|
||||
const evtTimeline = getEventTimeline(room, evtId);
|
||||
const absoluteIndex =
|
||||
@@ -693,7 +693,7 @@ export function RoomTimeline({ room, eventId, roomInputRef, editor }: RoomTimeli
|
||||
loadEventTimeline(evtId);
|
||||
}
|
||||
},
|
||||
[room, scrollToItem, loadEventTimeline]
|
||||
[room, scrollToItem, loadEventTimeline],
|
||||
);
|
||||
|
||||
useLiveTimelineRefresh(
|
||||
@@ -702,7 +702,7 @@ export function RoomTimeline({ room, eventId, roomInputRef, editor }: RoomTimeli
|
||||
if (liveTimelineLinked) {
|
||||
setTimeline(getInitialTimeline(room));
|
||||
}
|
||||
}, [room, liveTimelineLinked])
|
||||
}, [room, liveTimelineLinked]),
|
||||
);
|
||||
|
||||
// Stay at bottom when room editor resize
|
||||
@@ -725,7 +725,7 @@ export function RoomTimeline({ room, eventId, roomInputRef, editor }: RoomTimeli
|
||||
}
|
||||
};
|
||||
}, [getScrollElement, roomInputRef]),
|
||||
useCallback(() => roomInputRef.current, [roomInputRef])
|
||||
useCallback(() => roomInputRef.current, [roomInputRef]),
|
||||
);
|
||||
|
||||
const tryAutoMarkAsRead = useCallback(() => {
|
||||
@@ -745,7 +745,7 @@ export function RoomTimeline({ room, eventId, roomInputRef, editor }: RoomTimeli
|
||||
useCallback((entry: IntersectionObserverEntry) => {
|
||||
if (!entry.isIntersecting) setAtBottom(false);
|
||||
}, []),
|
||||
{ wait: 1000 }
|
||||
{ wait: 1000 },
|
||||
);
|
||||
useIntersectionObserver(
|
||||
useCallback(
|
||||
@@ -761,16 +761,16 @@ export function RoomTimeline({ room, eventId, roomInputRef, editor }: RoomTimeli
|
||||
}
|
||||
}
|
||||
},
|
||||
[debounceSetAtBottom, tryAutoMarkAsRead]
|
||||
[debounceSetAtBottom, tryAutoMarkAsRead],
|
||||
),
|
||||
useCallback(
|
||||
() => ({
|
||||
root: getScrollElement(),
|
||||
rootMargin: '100px',
|
||||
}),
|
||||
[getScrollElement]
|
||||
[getScrollElement],
|
||||
),
|
||||
useCallback(() => atBottomAnchorRef.current, [])
|
||||
useCallback(() => atBottomAnchorRef.current, []),
|
||||
);
|
||||
|
||||
useDocumentFocusChange(
|
||||
@@ -790,8 +790,8 @@ export function RoomTimeline({ room, eventId, roomInputRef, editor }: RoomTimeli
|
||||
tryAutoMarkAsRead();
|
||||
}
|
||||
},
|
||||
[tryAutoMarkAsRead, unreadInfo, handleOpenEvent]
|
||||
)
|
||||
[tryAutoMarkAsRead, unreadInfo, handleOpenEvent],
|
||||
),
|
||||
);
|
||||
|
||||
// Handle up arrow edit
|
||||
@@ -806,7 +806,7 @@ export function RoomTimeline({ room, eventId, roomInputRef, editor }: RoomTimeli
|
||||
isEmptyEditor(editor)
|
||||
) {
|
||||
const editableEvt = getLatestEditableEvt(room.getLiveTimeline(), (mEvt) =>
|
||||
canEditEvent(mx, mEvt)
|
||||
canEditEvent(mx, mEvt),
|
||||
);
|
||||
const editableEvtId = editableEvt?.getId();
|
||||
if (!editableEvtId) return;
|
||||
@@ -814,8 +814,8 @@ export function RoomTimeline({ room, eventId, roomInputRef, editor }: RoomTimeli
|
||||
evt.preventDefault();
|
||||
}
|
||||
},
|
||||
[mx, room, editor]
|
||||
)
|
||||
[mx, room, editor],
|
||||
),
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -931,7 +931,7 @@ export function RoomTimeline({ room, eventId, roomInputRef, editor }: RoomTimeli
|
||||
if (!targetId) return;
|
||||
handleOpenEvent(targetId);
|
||||
},
|
||||
[handleOpenEvent]
|
||||
[handleOpenEvent],
|
||||
);
|
||||
|
||||
const handleUserClick: MouseEventHandler<HTMLButtonElement> = useCallback(
|
||||
@@ -947,10 +947,10 @@ export function RoomTimeline({ room, eventId, roomInputRef, editor }: RoomTimeli
|
||||
room.roomId,
|
||||
space?.roomId,
|
||||
userId,
|
||||
evt.currentTarget.getBoundingClientRect()
|
||||
evt.currentTarget.getBoundingClientRect(),
|
||||
);
|
||||
},
|
||||
[room, space, openUserRoomProfile]
|
||||
[room, space, openUserRoomProfile],
|
||||
);
|
||||
const handleUsernameClick: MouseEventHandler<HTMLButtonElement> = useCallback(
|
||||
(evt) => {
|
||||
@@ -965,13 +965,13 @@ export function RoomTimeline({ room, eventId, roomInputRef, editor }: RoomTimeli
|
||||
createMentionElement(
|
||||
userId,
|
||||
name.startsWith('@') ? name : `@${name}`,
|
||||
userId === mx.getUserId()
|
||||
)
|
||||
userId === mx.getUserId(),
|
||||
),
|
||||
);
|
||||
ReactEditor.focus(editor);
|
||||
moveCursor(editor);
|
||||
},
|
||||
[mx, room, editor]
|
||||
[mx, room, editor],
|
||||
);
|
||||
|
||||
const handleReplyClick: MouseEventHandler<HTMLButtonElement> = useCallback(
|
||||
@@ -1001,7 +1001,7 @@ export function RoomTimeline({ room, eventId, roomInputRef, editor }: RoomTimeli
|
||||
setTimeout(() => ReactEditor.focus(editor), 100);
|
||||
}
|
||||
},
|
||||
[room, setReplyDraft, editor]
|
||||
[room, setReplyDraft, editor],
|
||||
);
|
||||
|
||||
const handleReactionToggle = useCallback(
|
||||
@@ -1022,10 +1022,10 @@ export function RoomTimeline({ room, eventId, roomInputRef, editor }: RoomTimeli
|
||||
mx.sendEvent(
|
||||
room.roomId,
|
||||
MessageEvent.Reaction as any,
|
||||
getReactionContent(targetEventId, key, rShortcode)
|
||||
getReactionContent(targetEventId, key, rShortcode),
|
||||
);
|
||||
},
|
||||
[mx, room]
|
||||
[mx, room],
|
||||
);
|
||||
const handleEdit = useCallback(
|
||||
(editEvtId?: string) => {
|
||||
@@ -1036,7 +1036,7 @@ export function RoomTimeline({ room, eventId, roomInputRef, editor }: RoomTimeli
|
||||
setEditId(undefined);
|
||||
ReactEditor.focus(editor);
|
||||
},
|
||||
[editor]
|
||||
[editor],
|
||||
);
|
||||
const { t } = useTranslation();
|
||||
|
||||
@@ -1938,7 +1938,7 @@ export function RoomTimeline({ room, eventId, roomInputRef, editor }: RoomTimeli
|
||||
/>
|
||||
</Event>
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
let prevEvent: MatrixEvent | undefined;
|
||||
@@ -2014,7 +2014,7 @@ export function RoomTimeline({ room, eventId, roomInputRef, editor }: RoomTimeli
|
||||
mEvent,
|
||||
item,
|
||||
timelineSet,
|
||||
collapsed
|
||||
collapsed,
|
||||
);
|
||||
prevEvent = mEvent;
|
||||
isPrevRendered = !!eventJSX;
|
||||
|
||||
Reference in New Issue
Block a user