Avoid repeated scollToMessage actions
This commit is contained in:
parent
11ea595457
commit
d2d2a230b6
1 changed files with 5 additions and 5 deletions
|
@ -45,7 +45,7 @@ export const SmartChatsTab = memo(function SmartChatsTab() {
|
||||||
const hasPendingUpdate = useSelector(getHasPendingUpdate);
|
const hasPendingUpdate = useSelector(getHasPendingUpdate);
|
||||||
const otherTabsUnreadStats = useSelector(getOtherTabsUnreadStats);
|
const otherTabsUnreadStats = useSelector(getOtherTabsUnreadStats);
|
||||||
const selectedConversationId = useSelector(getSelectedConversationId);
|
const selectedConversationId = useSelector(getSelectedConversationId);
|
||||||
const targetedMessage = useSelector(getTargetedMessage);
|
const targetedMessageId = useSelector(getTargetedMessage)?.id;
|
||||||
const targetedMessageSource = useSelector(getTargetedMessageSource);
|
const targetedMessageSource = useSelector(getTargetedMessageSource);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
@ -64,16 +64,16 @@ export const SmartChatsTab = memo(function SmartChatsTab() {
|
||||||
if (selectedConversationId !== lastOpenedConversationId.current) {
|
if (selectedConversationId !== lastOpenedConversationId.current) {
|
||||||
lastOpenedConversationId.current = selectedConversationId;
|
lastOpenedConversationId.current = selectedConversationId;
|
||||||
if (selectedConversationId) {
|
if (selectedConversationId) {
|
||||||
onConversationOpened(selectedConversationId, targetedMessage?.id);
|
onConversationOpened(selectedConversationId, targetedMessageId);
|
||||||
}
|
}
|
||||||
} else if (
|
} else if (
|
||||||
selectedConversationId &&
|
selectedConversationId &&
|
||||||
targetedMessage &&
|
targetedMessageId &&
|
||||||
targetedMessageSource !== TargetedMessageSource.Focus
|
targetedMessageSource !== TargetedMessageSource.Focus
|
||||||
) {
|
) {
|
||||||
scrollToMessage(selectedConversationId, targetedMessage?.id);
|
scrollToMessage(selectedConversationId, targetedMessageId);
|
||||||
}
|
}
|
||||||
}, [onConversationOpened, selectedConversationId, scrollToMessage, targetedMessage, targetedMessageSource]);
|
}, [onConversationOpened, selectedConversationId, scrollToMessage, targetedMessageId, targetedMessageSource]);
|
||||||
|
|
||||||
const prevConversationId = usePrevious(
|
const prevConversationId = usePrevious(
|
||||||
selectedConversationId,
|
selectedConversationId,
|
||||||
|
|
Loading…
Reference in a new issue