[FIX] Pop from room which you have been removed (#1819)

Co-authored-by: Diego Mello <diegolmello@gmail.com>
This commit is contained in:
Djorkaeff Alexandre 2020-03-04 08:49:54 -03:00 committed by GitHub
parent 524e163091
commit 4597ab6c78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 0 deletions

View File

@ -476,6 +476,7 @@ export default {
You_can_search_using_RegExp_eg: 'You can use RegExp. e.g. `/^text$/i`',
You_colon: 'You: ',
you_were_mentioned: 'you were mentioned',
You_were_removed_from_channel: 'You were removed from {{channel}}',
you: 'you',
You: 'You',
Logged_out_by_server: 'You\'ve been logged out by the server. Please log in again.',

View File

@ -427,6 +427,7 @@ export default {
You_can_search_using_RegExp_eg: 'Você pode usar expressões regulares, por exemplo `/^text$/i`',
You_colon: 'Você: ',
you_were_mentioned: 'você foi mencionado',
You_were_removed_from_channel: 'Você foi removido de {{channel}}',
you: 'você',
You: 'Você',
Your_invite_link_will_expire_after__usesLeft__uses: 'Seu link de convite irá vencer depois de {{usesLeft}} usos.',

View File

@ -13,6 +13,7 @@ import { notificationReceived } from '../../../actions/notification';
import { handlePayloadUserInteraction } from '../actions';
import buildMessage from '../helpers/buildMessage';
import RocketChat from '../../rocketchat';
import EventEmmiter from '../../../utils/events';
const removeListener = listener => listener.stop();
@ -238,6 +239,7 @@ export default function subscribeRooms() {
...threadMessagesToDelete
);
});
EventEmmiter.emit('removed', { rid: data.rid });
} catch (e) {
log(e);
}

View File

@ -229,6 +229,7 @@ class RoomView extends React.Component {
if (isTablet) {
EventEmitter.addEventListener(KEY_COMMAND, this.handleCommands);
}
EventEmitter.addEventListener('removed', this.handleRemoved);
console.timeEnd(`${ this.constructor.name } mount`);
}
@ -311,6 +312,7 @@ class RoomView extends React.Component {
if (isTablet) {
EventEmitter.removeListener(KEY_COMMAND, this.handleCommands);
}
EventEmitter.removeListener('removed', this.handleRemoved);
console.countReset(`${ this.constructor.name }.render calls`);
}
@ -551,6 +553,15 @@ class RoomView extends React.Component {
EventEmitter.removeListener('connected', this.handleConnected);
}
handleRemoved = ({ rid }) => {
const { room } = this.state;
const { navigation } = this.props;
if (rid === this.rid) {
navigation.pop();
showErrorAlert(I18n.t('You_were_removed_from_channel', { channel: this.getRoomTitle(room) }), I18n.t('Oops'));
}
}
internalSetState = (...args) => {
if (!this.mounted) {
return;