fix: Room history scroll position (#29335)
Co-authored-by: gabriellsh <40830821+gabriellsh@users.noreply.github.com>pull/29098/head^2
parent
059a92e876
commit
cebe359d13
@ -0,0 +1,5 @@ |
||||
--- |
||||
'@rocket.chat/meteor': minor |
||||
--- |
||||
|
||||
fix: Room history scrollbar position |
||||
@ -0,0 +1,23 @@ |
||||
import type { IRoom } from '@rocket.chat/core-typings'; |
||||
import { useEffect } from 'react'; |
||||
|
||||
import type { MessageListContextValue } from '../../../../../components/message/list/MessageListContext'; |
||||
import { RoomManager } from '../../../../../lib/RoomManager'; |
||||
|
||||
export function useRestoreScrollPosition( |
||||
roomId: IRoom['_id'], |
||||
scrollMessageList: Exclude<MessageListContextValue['scrollMessageList'], undefined>, |
||||
sendToBottom: () => void, |
||||
) { |
||||
useEffect(() => { |
||||
const store = RoomManager.getStore(roomId); |
||||
|
||||
if (store?.scroll && !store.atBottom) { |
||||
scrollMessageList(() => { |
||||
return { left: 30, top: store.scroll }; |
||||
}); |
||||
} else { |
||||
sendToBottom(); |
||||
} |
||||
}, [roomId, scrollMessageList, sendToBottom]); |
||||
} |
||||
Loading…
Reference in new issue