Skip to content

Commit

Permalink
Refactor: change the conditions which unread message appear
Browse files Browse the repository at this point in the history
  • Loading branch information
bell-won committed Dec 20, 2020
1 parent b6ec50f commit 0aabbe3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
6 changes: 3 additions & 3 deletions frontend/src/container/ChatRoom/ChatRoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,12 @@ const ChatRoom = ({ width }) => {
...messages,
...hasMyReaction([message], workspaceUserInfo),
])
if (isReading.current && document.hasFocus()) {
if (message.userInfo._id === workspaceUserInfo._id) {
setHasUnreadMessage(false)
scrollTo()
} else if (message.userInfo._id !== workspaceUserInfo._id)
} else if (!isReading.current && !document.hasFocus()) {
setHasUnreadMessage(true)
}
}

if (document.hidden) {
Expand Down Expand Up @@ -257,7 +258,6 @@ const UnreadMessage = styled.div`
background-color: ${COLOR.STARBLUE};
color: ${COLOR.WHITE};
width: 170px;
height: 50px;
margin-left: auto;
margin-right: auto;
position: sticky;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,16 @@ function ChannelBrowserCard({
setChannels()
handleClose()
}

return (
<ChannelBrowserCardStyle>
<ContentsArea>{title}</ContentsArea>
<ButtonArea>
<Button
handleClick={clickEvent}
type={joined ? 'leave' : undefined}
disabled={channelType == 0 || _id === defaultChannel}
disabled={_id === defaultChannel || (channelType === 0 && !joined)}
children={
channelType == 0
channelType === 0
? 'private'
: _id === defaultChannel
? 'Default channel'
Expand Down

0 comments on commit 0aabbe3

Please sign in to comment.