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