Unverified Commit 4597ab6c authored by Djorkaeff Alexandre's avatar Djorkaeff Alexandre Committed by GitHub
Browse files

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


Co-authored-by: default avatarDiego Mello <diegolmello@gmail.com>
parent 524e1630
......@@ -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.',
......
......@@ -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.',
......
......@@ -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);
}
......
......@@ -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;
......
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