Skip to content

Commit

Permalink
fix(scroll): fix delay on history initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
ph1p committed Aug 30, 2019
1 parent 796b1e7 commit 69bec6b
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/ui.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -230,12 +230,9 @@ const init = (SERVER_URL = 'https://figma-chat.ph1p.dev/') => {
});

// scroll to bottom
setTimeout(() => {
if (messagesEndRef.current) {
messagesEndRef.current.scrollTop =
messagesEndRef.current.scrollHeight;
}
}, 0);
if (messagesEndRef.current) {
messagesEndRef.current.scrollTop = messagesEndRef.current.scrollHeight;
}

return () => {
socket.off('online');
Expand Down Expand Up @@ -267,6 +264,11 @@ const init = (SERVER_URL = 'https://figma-chat.ph1p.dev/') => {
} else {
sendMainMessage('get-user-settings');
}

// scroll to bottom
if (messagesEndRef.current) {
messagesEndRef.current.scrollTop = messagesEndRef.current.scrollHeight;
}
}, [isMainReady, connection]);

// join room
Expand Down

0 comments on commit 69bec6b

Please sign in to comment.