* Select last channel viewed Now saving last channel id to local storage Reworked local storage saving * Feedback review
23 lines
759 B
JavaScript
23 lines
759 B
JavaScript
// Copyright (c) 2017 Mattermost, Inc. All Rights Reserved.
|
|
// See License.txt for license information.
|
|
|
|
import {batchActions} from 'redux-batched-actions';
|
|
|
|
import {ChannelTypes, TeamsTypes} from 'service/constants';
|
|
import {updateStorage} from 'app/actions/storage';
|
|
|
|
export function handleTeamChange(team) {
|
|
return async (dispatch, getState) => {
|
|
const storage = await updateStorage('currentTeamId', team.id);
|
|
const lastChannelForTeam = storage[team.id] ? storage[team.id].currentChannelId : '';
|
|
|
|
dispatch(batchActions([
|
|
{type: TeamsTypes.SELECT_TEAM, data: team.id},
|
|
{type: ChannelTypes.SELECT_CHANNEL, data: lastChannelForTeam}
|
|
]), getState);
|
|
};
|
|
}
|
|
|
|
export default {
|
|
handleTeamChange
|
|
};
|