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

MM-25640 - Leaving archived channel does not return user to the last viewed channel #5755

Merged
merged 4 commits into from
Jun 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion actions/views/channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import {browserHistory} from 'utils/browser_history';
import {Constants, ActionTypes, EventTypes, PostRequestTypes} from 'utils/constants';
import {isMobile} from 'utils/utils.jsx';
import LocalStorageStore from 'stores/local_storage_store.jsx';
import {isArchivedChannel} from 'utils/channel_utils';

export function checkAndSetMobileView() {
return (dispatch) => {
Expand Down Expand Up @@ -116,14 +117,17 @@ export function leaveChannel(channelId) {
const myPreferences = getMyPreferences(state);
const currentUserId = getCurrentUserId(state);
const currentTeam = getCurrentTeam(state);
const channel = getChannel(state, channelId);

if (isFavoriteChannel(myPreferences, channelId)) {
dispatch(unfavoriteChannel(channelId));
}

const teamUrl = getCurrentRelativeTeamUrl(state);
LocalStorageStore.removePreviousChannelName(currentUserId, currentTeam.id, state);

if (!isArchivedChannel(channel)) {
LocalStorageStore.removePreviousChannelName(currentUserId, currentTeam.id, state);
}
const {error} = await dispatch(leaveChannelRedux(channelId));
if (error) {
return {error};
Expand Down
11 changes: 8 additions & 3 deletions actions/views/channel.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,14 @@ jest.mock('utils/browser_history', () => ({
},
}));

jest.mock('utils/channel_utils.jsx', () => ({
getRedirectChannelNameForTeam: () => 'town-square',
}));
jest.mock('utils/channel_utils.jsx', () => {
const original = jest.requireActual('utils/channel_utils.jsx');

return {
...original,
getRedirectChannelNameForTeam: () => 'town-square',
};
});

jest.mock('actions/channel_actions.jsx', () => ({
openDirectChannelToUserId: jest.fn(() => ({type: ''})),
Expand Down