Skip to content

Commit

Permalink
runfix: mark last message not visible on unmount [WPB-9956] (#17743)
Browse files Browse the repository at this point in the history
* runfix: mark last message unvisible on unmount

* runfix: add deps array

* docs: add comment
  • Loading branch information
PatrykBuniX authored Jul 12, 2024
1 parent 9d78754 commit 7e05864
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/script/components/Conversation/Conversation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*
*/

import {UIEvent, useCallback, useState} from 'react';
import {UIEvent, useCallback, useEffect, useState} from 'react';

import cx from 'classnames';
import {container} from 'tsyringe';
Expand Down Expand Up @@ -124,6 +124,12 @@ export const Conversation = ({

const {addReadReceiptToBatch} = useReadReceiptSender(repositories.message);

useEffect(() => {
// When the component is mounted we want to make sure its conversation entity's last message is marked as visible
// not to display the jump to last message button initially
activeConversation?.isLastMessageVisible(true);
}, [activeConversation]);

const uploadImages = useCallback(
(images: File[]) => {
if (!activeConversation || isHittingUploadLimit(images, repositories.asset)) {
Expand Down
3 changes: 3 additions & 0 deletions src/script/components/MessagesList/Message/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ export const Message = (props: MessageParams & {scrollTo?: ScrollToElement}) =>
}
}, [isFocused]);

// When component is unmounted, it's not visible anymore
useEffect(() => onVisibilityLost, [onVisibilityLost]);

// set message elements focus for non content type mesages
// some non content type message has interactive element like invite people for member message
useEffect(() => {
Expand Down

0 comments on commit 7e05864

Please sign in to comment.