Commit 5cd8152a authored by Christopher Speller's avatar Christopher Speller Committed by Harrison Healey

Fixing last channel on team not being remembered after refresh. (#875)

parent df1ed3d8
......@@ -63,7 +63,7 @@ export function emitChannelClickEvent(channel) {
reloadIfServerVersionChanged();
});
BrowserStore.setGlobalItem(chan.team_id, chan.id);
BrowserStore.setGlobalItem(Constants.PREV_CHANNEL_KEY + chan.team_id, chan.name);
loadProfilesForSidebar();
......
......@@ -3,7 +3,6 @@
import {connect} from 'react-redux';
import {getTeamByName} from 'mattermost-redux/selectors/entities/teams';
import {getChannel} from 'mattermost-redux/selectors/entities/channels';
import Constants from 'utils/constants';
import {getGlobalItem} from 'selectors/storage';
......@@ -11,17 +10,12 @@ import {getGlobalItem} from 'selectors/storage';
import CenterChannel from './center_channel';
const getLastChannelPath = (state, teamName) => {
let channelName = Constants.DEFAULT_CHANNEL;
const team = getTeamByName(state, teamName);
if (team) {
const channelId = getGlobalItem(state, team.id, null);
const channel = getChannel(state, channelId);
if (channel) {
channelName = channel.name;
}
return getGlobalItem(state, Constants.PREV_CHANNEL_KEY + team.id, Constants.DEFAULT_CHANNEL);
}
return channelName;
return Constants.DEFAULT_CHANNEL;
};
const mapStateToProps = (state, ownProps) => ({
......
......@@ -1117,6 +1117,7 @@ export const Constants = {
SEARCH_POST: 'searchpost',
CHANNEL_ID_LENGTH: 26,
TRANSPARENT_PIXEL: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=',
PREV_CHANNEL_KEY: 'team_prev_channel:',
};
export default Constants;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment