mirror of
https://github.com/Qortal/qortal-mobile.git
synced 2025-03-28 08:15:55 +00:00
improve chat load
This commit is contained in:
parent
7cee88643d
commit
baabe65903
@ -383,6 +383,8 @@ const clearEditorContent = () => {
|
|||||||
|
|
||||||
const onReply = useCallback((message)=> {
|
const onReply = useCallback((message)=> {
|
||||||
setReplyMessage(message)
|
setReplyMessage(message)
|
||||||
|
editorRef?.current?.chain().focus()
|
||||||
|
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
|
|
||||||
|
@ -108,32 +108,40 @@ export const ChatList = ({ initialMessages, myAddress, tempMessages, chatId, onR
|
|||||||
getScrollElement: () => parentRef.current,
|
getScrollElement: () => parentRef.current,
|
||||||
estimateSize: () => 80, // Provide an estimated height of items, adjust this as needed
|
estimateSize: () => 80, // Provide an estimated height of items, adjust this as needed
|
||||||
overscan: 10, // Number of items to render outside the visible area to improve smoothness
|
overscan: 10, // Number of items to render outside the visible area to improve smoothness
|
||||||
measureElement:
|
getItemKey: React.useCallback(
|
||||||
typeof window !== 'undefined' &&
|
(index) => messages[index].signature,
|
||||||
navigator.userAgent.indexOf('Firefox') === -1
|
[messages]
|
||||||
? element => {
|
),
|
||||||
return element?.getBoundingClientRect().height
|
|
||||||
}
|
|
||||||
: undefined,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={{
|
<div style={{
|
||||||
height: '100%',
|
height: '100%',
|
||||||
position: 'relative'
|
position: 'relative',
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column'
|
||||||
}}>
|
}}>
|
||||||
<div ref={parentRef} style={{ height: '100%', overflow: 'auto', position: 'relative', display: 'flex' }}>
|
<div
|
||||||
<div
|
ref={parentRef}
|
||||||
style={{
|
className="List"
|
||||||
width: '100%',
|
style={{ flexGrow: 1, overflow: 'auto', position: 'relative', display: 'flex', height: '0px' }}
|
||||||
position: 'relative',
|
|
||||||
display: 'flex',
|
|
||||||
flexDirection: 'column',
|
|
||||||
alignItems: 'center', // Center items horizontally
|
|
||||||
gap: '10px', // Add gap between items
|
|
||||||
flexGrow: 1
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
height: rowVirtualizer.getTotalSize(),
|
||||||
|
width: '100%',
|
||||||
|
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
position: 'absolute',
|
||||||
|
top: 0,
|
||||||
|
left: 0,
|
||||||
|
width: '100%',
|
||||||
|
// transform: `translateY(${rowVirtualizer.getVirtualItems()[0]?.start ?? 0}px)`,
|
||||||
|
}}
|
||||||
|
>
|
||||||
{rowVirtualizer.getVirtualItems().map((virtualRow) => {
|
{rowVirtualizer.getVirtualItems().map((virtualRow) => {
|
||||||
const index = virtualRow.index;
|
const index = virtualRow.index;
|
||||||
let message = messages[index];
|
let message = messages[index];
|
||||||
@ -205,7 +213,7 @@ export const ChatList = ({ initialMessages, myAddress, tempMessages, chatId, onR
|
|||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
{showScrollButton && (
|
{showScrollButton && (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user