Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Commit

Permalink
Revert "MM-29929 Fix for unread messages toast on marking channel as …
Browse files Browse the repository at this point in the history
…unread (#7028)"

This reverts commit 92f5d86.
  • Loading branch information
hmhealey committed Jan 7, 2021
1 parent d718bdb commit 47dbd28
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
20 changes: 9 additions & 11 deletions components/toast_wrapper/toast_wrapper.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,17 +98,15 @@ class ToastWrapper extends React.PureComponent {
showMessageHistoryToast = props.initScrollOffsetFromBottom > THRESHOLD_FROM_BOTTOM || !props.atLatestPost;
}

if (!props.atBottom) {
// show unread toast when a channel is marked as unread
if (props.channelMarkedAsUnread && !prevState.channelMarkedAsUnread && !prevState.showUnreadToast) {
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 = 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) {
showUnreadToast = props.initScrollOffsetFromBottom > THRESHOLD_FROM_BOTTOM;
}
}

Expand Down
6 changes: 3 additions & 3 deletions components/toast_wrapper/toast_wrapper.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ describe('components/ToastWrapper', () => {
const wrapper = shallowWithIntl(<ToastWrapper {...props}/>);
expect(wrapper.state('showUnreadToast')).toBe(false);
wrapper.setProps({channelMarkedAsUnread: true, atBottom: false});
expect(wrapper.state('showUnreadToast')).toBe(true);
expect(wrapper.state('showUnreadToast')).toBe(false);
});

test('Should have unread toast channel is marked as unread again', () => {
Expand All @@ -170,12 +170,12 @@ describe('components/ToastWrapper', () => {
],
});

expect(wrapper.state('showUnreadToast')).toBe(true);
expect(wrapper.state('showUnreadToast')).toBe(false);
wrapper.setProps({atBottom: true});
expect(wrapper.state('showUnreadToast')).toBe(false);
wrapper.setProps({atBottom: false});
wrapper.setProps({lastViewedAt: 12342});
expect(wrapper.state('showUnreadToast')).toBe(true);
expect(wrapper.state('showUnreadToast')).toBe(false);
});

test('Should have archive toast if channel is not atLatestPost and focusedPostId exists', () => {
Expand Down

0 comments on commit 47dbd28

Please sign in to comment.