[FIX] Logout (#497)
* [FIX] Logout * Removed realm instances on rooms list
This commit is contained in:
parent
abc61342b0
commit
ed1988d64d
|
@ -494,9 +494,11 @@ const RocketChat = {
|
||||||
}
|
}
|
||||||
AsyncStorage.removeItem(TOKEN_KEY);
|
AsyncStorage.removeItem(TOKEN_KEY);
|
||||||
AsyncStorage.removeItem(`${ TOKEN_KEY }-${ server }`);
|
AsyncStorage.removeItem(`${ TOKEN_KEY }-${ server }`);
|
||||||
setTimeout(() => {
|
try {
|
||||||
database.deleteAll();
|
database.deleteAll();
|
||||||
}, 1500);
|
} catch (error) {
|
||||||
|
console.warn(error);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
disconnect() {
|
disconnect() {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -134,7 +134,7 @@ export default class RoomItem extends React.Component {
|
||||||
name: PropTypes.string.isRequired,
|
name: PropTypes.string.isRequired,
|
||||||
baseUrl: PropTypes.string.isRequired,
|
baseUrl: PropTypes.string.isRequired,
|
||||||
StoreLastMessage: PropTypes.bool,
|
StoreLastMessage: PropTypes.bool,
|
||||||
_updatedAt: PropTypes.instanceOf(Date),
|
_updatedAt: PropTypes.string,
|
||||||
lastMessage: PropTypes.object,
|
lastMessage: PropTypes.object,
|
||||||
showLastMessage: PropTypes.bool,
|
showLastMessage: PropTypes.bool,
|
||||||
favorite: PropTypes.bool,
|
favorite: PropTypes.bool,
|
||||||
|
@ -159,10 +159,10 @@ export default class RoomItem extends React.Component {
|
||||||
const oldlastMessage = lastMessage;
|
const oldlastMessage = lastMessage;
|
||||||
const newLastmessage = nextProps.lastMessage;
|
const newLastmessage = nextProps.lastMessage;
|
||||||
|
|
||||||
if (oldlastMessage && newLastmessage && oldlastMessage.ts.toGMTString() !== newLastmessage.ts.toGMTString()) {
|
if (oldlastMessage && newLastmessage && oldlastMessage.ts !== newLastmessage.ts) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (_updatedAt && nextProps._updatedAt && nextProps._updatedAt.toGMTString() !== _updatedAt.toGMTString()) {
|
if (_updatedAt && nextProps._updatedAt && nextProps._updatedAt !== _updatedAt) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line react/destructuring-assignment
|
// eslint-disable-next-line react/destructuring-assignment
|
||||||
|
|
|
@ -102,7 +102,6 @@ const handleLogout = function* handleLogout() {
|
||||||
if (server) {
|
if (server) {
|
||||||
try {
|
try {
|
||||||
yield put(appStart('outside'));
|
yield put(appStart('outside'));
|
||||||
// yield delay(300);
|
|
||||||
yield call(logoutCall, { server });
|
yield call(logoutCall, { server });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log('handleLogout', e);
|
log('handleLogout', e);
|
||||||
|
|
|
@ -225,9 +225,9 @@ export default class RoomsListView extends LoggedView {
|
||||||
// unread
|
// unread
|
||||||
if (showUnread) {
|
if (showUnread) {
|
||||||
this.unread = this.data.filtered('archived != true && open == true').filtered('(unread > 0 || alert == true)');
|
this.unread = this.data.filtered('archived != true && open == true').filtered('(unread > 0 || alert == true)');
|
||||||
unread = this.unread.slice();
|
unread = this.removeRealmInstance(this.unread);
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.unread.addListener(() => this.setState({ unread: this.unread.slice() }));
|
this.unread.addListener(() => this.setState({ unread: this.removeRealmInstance(this.unread) }));
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.removeListener(unread);
|
this.removeListener(unread);
|
||||||
|
@ -235,9 +235,9 @@ export default class RoomsListView extends LoggedView {
|
||||||
// favorites
|
// favorites
|
||||||
if (showFavorites) {
|
if (showFavorites) {
|
||||||
this.favorites = this.data.filtered('f == true');
|
this.favorites = this.data.filtered('f == true');
|
||||||
favorites = this.favorites.slice();
|
favorites = this.removeRealmInstance(this.favorites);
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.favorites.addListener(() => this.setState({ favorites: this.favorites.slice() }));
|
this.favorites.addListener(() => this.setState({ favorites: this.removeRealmInstance(this.favorites) }));
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.removeListener(favorites);
|
this.removeListener(favorites);
|
||||||
|
@ -246,21 +246,25 @@ export default class RoomsListView extends LoggedView {
|
||||||
if (groupByType) {
|
if (groupByType) {
|
||||||
// channels
|
// channels
|
||||||
this.channels = this.data.filtered('t == $0', 'c');
|
this.channels = this.data.filtered('t == $0', 'c');
|
||||||
channels = this.channels.slice();
|
channels = this.removeRealmInstance(this.channels);
|
||||||
|
|
||||||
// private
|
// private
|
||||||
this.privateGroup = this.data.filtered('t == $0', 'p');
|
this.privateGroup = this.data.filtered('t == $0', 'p');
|
||||||
privateGroup = this.privateGroup.slice();
|
privateGroup = this.removeRealmInstance(this.privateGroup);
|
||||||
|
|
||||||
// direct
|
// direct
|
||||||
this.direct = this.data.filtered('t == $0', 'd');
|
this.direct = this.data.filtered('t == $0', 'd');
|
||||||
direct = this.direct.slice();
|
direct = this.removeRealmInstance(this.direct);
|
||||||
|
|
||||||
// livechat
|
// livechat
|
||||||
this.livechat = this.data.filtered('t == $0', 'l');
|
this.livechat = this.data.filtered('t == $0', 'l');
|
||||||
livechat = this.livechat.slice();
|
livechat = this.removeRealmInstance(this.livechat);
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.channels.addListener(() => this.setState({ channels: this.channels.slice() }));
|
this.channels.addListener(() => this.setState({ channels: this.removeRealmInstance(this.channels) }));
|
||||||
this.privateGroup.addListener(() => this.setState({ privateGroup: this.privateGroup.slice() }));
|
this.privateGroup.addListener(() => this.setState({ privateGroup: this.removeRealmInstance(this.privateGroup) }));
|
||||||
this.direct.addListener(() => this.setState({ direct: this.direct.slice() }));
|
this.direct.addListener(() => this.setState({ direct: this.removeRealmInstance(this.direct) }));
|
||||||
this.livechat.addListener(() => this.setState({ livechat: this.livechat.slice() }));
|
this.livechat.addListener(() => this.setState({ livechat: this.removeRealmInstance(this.livechat) }));
|
||||||
});
|
});
|
||||||
this.removeListener(this.chats);
|
this.removeListener(this.chats);
|
||||||
} else {
|
} else {
|
||||||
|
@ -270,9 +274,12 @@ export default class RoomsListView extends LoggedView {
|
||||||
} else {
|
} else {
|
||||||
this.chats = this.data;
|
this.chats = this.data;
|
||||||
}
|
}
|
||||||
chats = this.chats.slice();
|
chats = this.removeRealmInstance(this.chats);
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.chats.addListener(() => this.setState({ chats: this.chats.slice() }));
|
this.chats.addListener(() => {
|
||||||
|
this.setState({ chats: this.removeRealmInstance(this.chats) });
|
||||||
|
});
|
||||||
});
|
});
|
||||||
this.removeListener(this.channels);
|
this.removeListener(this.channels);
|
||||||
this.removeListener(this.privateGroup);
|
this.removeListener(this.privateGroup);
|
||||||
|
@ -290,6 +297,11 @@ export default class RoomsListView extends LoggedView {
|
||||||
}, 200);
|
}, 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
removeRealmInstance = (data) => {
|
||||||
|
const array = Array.from(data);
|
||||||
|
return JSON.parse(JSON.stringify(array));
|
||||||
|
}
|
||||||
|
|
||||||
removeListener = (data) => {
|
removeListener = (data) => {
|
||||||
if (data && data.removeAllListeners) {
|
if (data && data.removeAllListeners) {
|
||||||
data.removeAllListeners();
|
data.removeAllListeners();
|
||||||
|
|
Loading…
Reference in New Issue