This repository has been archived by the owner on Mar 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
[MM-24436]- Add a threshold from bottom for new messages toast #5828
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
12061bd
Changed the buffer value to be considered from bottom for the toast m…
sridhar02 9f83968
test value changes related to isAtBottom function
sridhar02 c86b515
Changes are set to previous values as this is not right approach
sridhar02 895a868
added the condition for the offset from bottom greater than 1000px
sridhar02 67b0848
Change the test conditions according to new condition to show the toa…
sridhar02 f6f6454
logic change
sridhar02 0fafa05
eslint corrections
sridhar02 5668baa
added a test that fails if the scroll from bottom is less than 1000px
sridhar02 a0afef1
add constant THRESHOLD_FROM_BOTTOM and replace 1000 value
sridhar02 804ef42
Bug fix for toast flashing when you mark as unread
sridhar02 9e35e46
bug fix
sridhar02 91597ca
tests resolved
sridhar02 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ import Constants from 'utils/constants'; | |
import {browserHistory} from 'utils/browser_history'; | ||
|
||
const TOAST_TEXT_COLLAPSE_WIDTH = 500; | ||
const THRESHOLD_FROM_BOTTOM = 1000; | ||
|
||
const TOAST_REL_RANGES = [ | ||
RelativeRanges.TODAY_YESTERDAY, | ||
|
@@ -87,25 +88,26 @@ class ToastWrapper extends React.PureComponent { | |
} else { | ||
unreadCount = prevState.unreadCountInChannel + props.newRecentMessagesCount; | ||
} | ||
if (props.atBottom !== null) { | ||
// show unread toast on mount when channel is not at bottom and unread count greater than 0 | ||
if (typeof showUnreadToast === 'undefined') { | ||
showUnreadToast = unreadCount > 0 && props.initScrollOffsetFromBottom > THRESHOLD_FROM_BOTTOM; | ||
} | ||
|
||
// show unread toast on mount when channel is not at bottom and unread count greater than 0 | ||
if (typeof showUnreadToast === 'undefined' && props.atBottom !== null) { | ||
showUnreadToast = unreadCount > 0 && !props.atBottom; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a reason to remove this check "!props.atBottom" ? I guess it might help resolving the bug? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. previously it is present as
i have changed to
which will get the solution for getting the toast from the bottom at 1000px |
||
} | ||
|
||
if (typeof showMessageHistoryToast === 'undefined' && props.focusedPostId !== '' && props.atBottom !== null) { | ||
showMessageHistoryToast = props.initScrollOffsetFromBottom > 1000 || !props.atLatestPost; | ||
} | ||
if (typeof showMessageHistoryToast === 'undefined' && props.focusedPostId !== '') { | ||
showMessageHistoryToast = props.initScrollOffsetFromBottom > THRESHOLD_FROM_BOTTOM || !props.atLatestPost; | ||
} | ||
|
||
// show unread toast when a channel is marked as unread | ||
if (props.channelMarkedAsUnread && !props.atBottom && !prevState.channelMarkedAsUnread && !prevState.showUnreadToast) { | ||
showUnreadToast = true; | ||
} | ||
// show unread toast when a channel is marked as unread | ||
if (props.channelMarkedAsUnread && !prevState.channelMarkedAsUnread && !prevState.showUnreadToast) { | ||
showUnreadToast = props.initScrollOffsetFromBottom > THRESHOLD_FROM_BOTTOM; | ||
} | ||
|
||
// show unread toast when a channel is remarked as unread using the change in lastViewedAt | ||
// lastViewedAt changes only if a channel is remarked as unread in channelMarkedAsUnread state | ||
if (props.channelMarkedAsUnread && props.lastViewedAt !== prevState.lastViewedAt && !props.atBottom) { | ||
showUnreadToast = true; | ||
// show unread toast when a channel is remarked as unread using the change in lastViewedAt | ||
// lastViewedAt changes only if a channel is remarked as unread in channelMarkedAsUnread state | ||
if (props.channelMarkedAsUnread && props.lastViewedAt !== prevState.lastViewedAt) { | ||
showUnreadToast = props.initScrollOffsetFromBottom > THRESHOLD_FROM_BOTTOM; | ||
} | ||
} | ||
|
||
if (!showUnreadToast && unreadCount > 0 && !props.atBottom && (props.lastViewedBottom < props.latestPostTimeStamp)) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor nitpick, can this
1000
scroll be a named constant so it can be more easily read?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes done