From f365874c9f55c9eac554d036595e1d8c6c706ecd Mon Sep 17 00:00:00 2001 From: WofWca Date: Tue, 7 Jan 2025 16:31:37 +0400 Subject: [PATCH] refactor: separate "loading" message components This is a preparation for adding `useRovingTabindex()` to them. --- .../src/components/message/MessageList.tsx | 67 ++++++++++++------- 1 file changed, 44 insertions(+), 23 deletions(-) diff --git a/packages/frontend/src/components/message/MessageList.tsx b/packages/frontend/src/components/message/MessageList.tsx index 81bf8180d7..4007061ba2 100644 --- a/packages/frontend/src/components/message/MessageList.tsx +++ b/packages/frontend/src/components/message/MessageList.tsx @@ -829,35 +829,17 @@ export const MessageListInner = React.memo( } else if (message?.kind === 'loadingError') { // TODO shall we add `useRovingTabindex` here as well? return ( -
-
- loading message {messageId.msg_id} failed:{' '} - {message.error} -
-
+ ) } else { // setTimeout tells it to call method in next event loop iteration, so after rendering // it is debounced later so we can call it here multiple times and it's ok setTimeout(loadMissingMessages) // TODO shall we add `useRovingTabindex` here as well? - return ( -
-
- Loading Message {messageId.msg_id} -
-
- ) + return } } })} @@ -877,6 +859,45 @@ export const MessageListInner = React.memo( } ) +function MessageLoadingError({ + messageId, + message, +}: { + messageId: T.MessageListItem & { kind: 'message' } + message: T.MessageLoadResult +}) { + return ( +
+
+ loading message {messageId.msg_id} failed: {message.error} +
+
+ ) +} +function MessageLoading({ + messageId, +}: { + messageId: T.MessageListItem & { kind: 'message' } +}) { + return ( +
+
+ Loading Message {messageId.msg_id} +
+
+ ) +} + function JumpDownButton({ countUnreadMessages, jumpToMessage,