forked from Ivasoft/mattermost-mobile
MM-11606: Back to prev channel on close archived channel (#2183)
This commit is contained in:
@@ -297,6 +297,8 @@ export function selectPenultimateChannel(teamId) {
|
||||
(lastChannel.delete_at === 0 || viewArchivedChannels) &&
|
||||
(lastChannel.team_id === teamId || isDMVisible || isGMVisible)
|
||||
) {
|
||||
dispatch(setChannelLoading(true));
|
||||
dispatch(setChannelDisplayName(lastChannel.display_name));
|
||||
dispatch(handleSelectChannel(lastChannelId));
|
||||
dispatch(markChannelAsRead(lastChannelId));
|
||||
return;
|
||||
|
||||
@@ -7,14 +7,14 @@ import {connect} from 'react-redux';
|
||||
import {General} from 'mattermost-redux/constants';
|
||||
import {createPost} from 'mattermost-redux/actions/posts';
|
||||
import {setStatus} from 'mattermost-redux/actions/users';
|
||||
import {getCurrentChannel, isCurrentChannelReadOnly, getDefaultChannel} from 'mattermost-redux/selectors/entities/channels';
|
||||
import {getCurrentChannel, isCurrentChannelReadOnly} from 'mattermost-redux/selectors/entities/channels';
|
||||
import {canUploadFilesOnMobile, getConfig} from 'mattermost-redux/selectors/entities/general';
|
||||
import {getTheme} from 'mattermost-redux/selectors/entities/preferences';
|
||||
import {getCurrentUserId, getStatusForUserId} from 'mattermost-redux/selectors/entities/users';
|
||||
|
||||
import {executeCommand} from 'app/actions/views/command';
|
||||
import {addReactionToLatestPost} from 'app/actions/views/emoji';
|
||||
import {handlePostDraftChanged, setChannelDisplayName, setChannelLoading} from 'app/actions/views/channel';
|
||||
import {handlePostDraftChanged, selectPenultimateChannel} from 'app/actions/views/channel';
|
||||
import {handleClearFiles, handleClearFailedFiles, handleRemoveLastFile, initUploadFiles} from 'app/actions/views/file_upload';
|
||||
import {handleCommentDraftChanged, handleCommentDraftSelectionChanged} from 'app/actions/views/thread';
|
||||
import {userTyping} from 'app/actions/views/typing';
|
||||
@@ -44,6 +44,7 @@ function mapStateToProps(state, ownProps) {
|
||||
|
||||
return {
|
||||
channelId: ownProps.channelId || (currentChannel ? currentChannel.id : ''),
|
||||
channelTeamId: currentChannel.team_id,
|
||||
canUploadFiles: canUploadFilesOnMobile(state),
|
||||
channelIsLoading: state.views.channel.loading,
|
||||
channelIsReadOnly: isCurrentChannelReadOnly(state),
|
||||
@@ -56,7 +57,6 @@ function mapStateToProps(state, ownProps) {
|
||||
theme: getTheme(state),
|
||||
uploadFileRequestStatus: state.requests.files.uploadFiles.status,
|
||||
value: currentDraft.draft,
|
||||
defaultChannel: getDefaultChannel(state),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -75,8 +75,7 @@ function mapDispatchToProps(dispatch) {
|
||||
userTyping,
|
||||
handleCommentDraftSelectionChanged,
|
||||
setStatus,
|
||||
setChannelDisplayName,
|
||||
setChannelLoading,
|
||||
selectPenultimateChannel,
|
||||
}, dispatch),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -38,11 +38,11 @@ export default class PostTextbox extends PureComponent {
|
||||
userTyping: PropTypes.func.isRequired,
|
||||
handleCommentDraftSelectionChanged: PropTypes.func.isRequired,
|
||||
setStatus: PropTypes.func.isRequired,
|
||||
setChannelDisplayName: PropTypes.func.isRequired,
|
||||
setChannelLoading: PropTypes.func.isRequired,
|
||||
selectPenultimateChannel: PropTypes.func.isRequired,
|
||||
}).isRequired,
|
||||
canUploadFiles: PropTypes.bool.isRequired,
|
||||
channelId: PropTypes.string.isRequired,
|
||||
channelTeamId: PropTypes.string.isRequired,
|
||||
channelIsLoading: PropTypes.bool,
|
||||
channelIsReadOnly: PropTypes.bool.isRequired,
|
||||
currentUserId: PropTypes.string.isRequired,
|
||||
@@ -56,7 +56,6 @@ export default class PostTextbox extends PureComponent {
|
||||
value: PropTypes.string.isRequired,
|
||||
userIsOutOfOffice: PropTypes.bool.isRequired,
|
||||
channelIsArchived: PropTypes.bool,
|
||||
defaultChannel: PropTypes.object,
|
||||
onCloseChannel: PropTypes.func,
|
||||
};
|
||||
|
||||
@@ -460,11 +459,8 @@ export default class PostTextbox extends PureComponent {
|
||||
};
|
||||
|
||||
onCloseChannelPress = () => {
|
||||
const {defaultChannel, channelId, onCloseChannel} = this.props;
|
||||
const {setChannelDisplayName, setChannelLoading} = this.props.actions;
|
||||
setChannelLoading(true);
|
||||
setChannelDisplayName(defaultChannel.display_name);
|
||||
EventEmitter.emit('switch_channel', defaultChannel, channelId);
|
||||
const {onCloseChannel, channelTeamId} = this.props;
|
||||
this.props.actions.selectPenultimateChannel(channelTeamId);
|
||||
if (onCloseChannel) {
|
||||
onCloseChannel();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user