Skip to content

Conversation

@dmytro-kucherenko
Copy link
Collaborator

Done:

  • the chat list state displays the list with the previously selected chat after reloading the page when a chat that doesn't fit on the page is selected
2023-09-30.13-16-42.mp4

Comment on lines +63 to +67
useEffect(() => {
if (chatsDataStatus === DataStatus.FULFILLED) {
setIsChatsLoaded(true);
}
}, [chatsDataStatus, setIsChatsLoaded]);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need a state for this? Can't we simply check like this?

const isChatsLoaded = chatsDataStatus === DataStatus.FULFILLED

Copy link
Collaborator Author

@dmytro-kucherenko dmytro-kucherenko Sep 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@HIMDanny We can't. Scroll to the selected card should be only on first chats loading, because then data status will change on every search request

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now I see, thanks for clarification

Copy link
Collaborator

@HIMDanny HIMDanny Sep 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw, we also can use ref for this to not cause a rerender after setIsChatLoaded(true)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@HIMDanny What do you mean by saying use ref?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nevermind, now I am not sure whether it will work)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: In Code Review

Development

Successfully merging this pull request may close these issues.

3 participants