File tree Expand file tree Collapse file tree 3 files changed +11
-13
lines changed
Expand file tree Collapse file tree 3 files changed +11
-13
lines changed Original file line number Diff line number Diff line change @@ -84,27 +84,26 @@ const MessageList: React.FC<MessageListProps> = (props: MessageListProps) => {
8484 } ) ;
8585 }
8686
87- // save the lastest scroll bottom value
87+ // Save the lastest scroll bottom value
8888 if ( scrollRef ?. current ) {
8989 const current = scrollRef ?. current ;
9090 setScrollBottom ( current . scrollHeight - current . scrollTop - current . offsetHeight )
9191 }
9292
93- // do this later
94- setTimeout ( ( ) => {
95- // mark as read if scroll is at end
96- if ( ! disableMarkAsRead && clientHeight + scrollTop === scrollHeight ) {
93+ if ( ! disableMarkAsRead && isAboutSame ( clientHeight + scrollTop , scrollHeight , 10 ) ) {
94+ // Mark as read if scroll is at end
95+ setTimeout ( ( ) => {
9796 messagesDispatcher ( {
9897 type : messageActionTypes . MARK_AS_READ ,
9998 payload : { channel : currentGroupChannel } ,
10099 } ) ;
101100 try {
102- currentGroupChannel ?. markAsRead ( ) ;
101+ currentGroupChannel ?. markAsRead ?. ( ) ;
103102 } catch {
104103 //
105104 }
106- }
107- } , 500 ) ;
105+ } , 500 ) ;
106+ }
108107 } ;
109108
110109 const onClickScrollBot = ( ) => {
Original file line number Diff line number Diff line change @@ -56,7 +56,8 @@ function useHandleChannelEvents({
5656 let scrollToEnd = false ;
5757 try {
5858 const { current } = scrollRef ;
59- scrollToEnd = current . offsetHeight + current . scrollTop >= current . scrollHeight ;
59+ scrollToEnd = current . offsetHeight + current . scrollTop >= current . scrollHeight - 10 ;
60+ // 10 is a buffer
6061 } catch ( error ) {
6162 //
6263 }
Original file line number Diff line number Diff line change 11import './index.scss' ;
2- import React , { useMemo } from 'react' ;
2+ import React from 'react' ;
33import format from 'date-fns/format' ;
44import { GroupChannel } from '@sendbird/chat/groupChannel' ;
55import { FileMessage , UserMessage } from '@sendbird/chat/message' ;
@@ -29,9 +29,7 @@ export default function MessageStatus({
2929 channel,
3030} : MessageStatusProps ) : React . ReactElement {
3131 const { dateLocale } = useLocalization ( ) ;
32- const status = useMemo ( ( ) => (
33- getOutgoingMessageState ( channel , message )
34- ) , [ channel , message ] ) ;
32+ const status = getOutgoingMessageState ( channel , message ) ;
3533 const hideMessageStatusIcon = channel ?. isGroupChannel ?.( ) && (
3634 ( channel . isSuper || channel . isPublic || channel . isBroadcast )
3735 && ! ( status === OutgoingMessageStates . PENDING || status === OutgoingMessageStates . FAILED )
You can’t perform that action at this time.
0 commit comments