Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions src/smart-components/Channel/components/MessageList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,27 +84,26 @@ const MessageList: React.FC<MessageListProps> = (props: MessageListProps) => {
});
}

// save the lastest scroll bottom value
// Save the lastest scroll bottom value
if (scrollRef?.current) {
const current = scrollRef?.current;
setScrollBottom(current.scrollHeight - current.scrollTop - current.offsetHeight)
}

// do this later
setTimeout(() => {
// mark as read if scroll is at end
if (!disableMarkAsRead && clientHeight + scrollTop === scrollHeight) {
if (!disableMarkAsRead && isAboutSame(clientHeight + scrollTop, scrollHeight, 10)) {
// Mark as read if scroll is at end
setTimeout(() => {
messagesDispatcher({
type: messageActionTypes.MARK_AS_READ,
payload: { channel: currentGroupChannel },
});
try {
currentGroupChannel?.markAsRead();
currentGroupChannel?.markAsRead?.();
} catch {
//
}
}
}, 500);
}, 500);
}
};

const onClickScrollBot = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ function useHandleChannelEvents({
let scrollToEnd = false;
try {
const { current } = scrollRef;
scrollToEnd = current.offsetHeight + current.scrollTop >= current.scrollHeight;
scrollToEnd = current.offsetHeight + current.scrollTop >= current.scrollHeight - 10;
// 10 is a buffer
} catch (error) {
//
}
Expand Down
6 changes: 2 additions & 4 deletions src/ui/MessageStatus/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import './index.scss';
import React, { useMemo } from 'react';
import React from 'react';
import format from 'date-fns/format';
import { GroupChannel } from '@sendbird/chat/groupChannel';
import { FileMessage, UserMessage } from '@sendbird/chat/message';
Expand Down Expand Up @@ -29,9 +29,7 @@ export default function MessageStatus({
channel,
}: MessageStatusProps): React.ReactElement {
const { dateLocale } = useLocalization();
const status = useMemo(() => (
getOutgoingMessageState(channel, message)
), [channel, message]);
const status = getOutgoingMessageState(channel, message);
const hideMessageStatusIcon = channel?.isGroupChannel?.() && (
(channel.isSuper || channel.isPublic || channel.isBroadcast)
&& !(status === OutgoingMessageStates.PENDING || status === OutgoingMessageStates.FAILED)
Expand Down