[IMPROVEMENT] Load team's rooms from local database on team leave (#3185)

* [IMPROVEMENT] Search team list rooms of user in watermelon db

* Minor nitpick

Co-authored-by: Diego Mello <diegolmello@gmail.com>
This commit is contained in:
Reinaldo Neto 2021-06-04 17:23:31 -03:00 committed by GitHub
parent abf3945f32
commit fa00ef92ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 4 deletions

View File

@ -461,11 +461,16 @@ class RoomActionsView extends React.Component {
const { navigation } = this.props;
try {
const result = await RocketChat.teamListRoomsOfUser({ teamId: room.teamId, userId: room.u._id });
const db = database.active;
const subCollection = db.get('subscriptions');
const rooms = await subCollection.query(
Q.where('team_id', Q.eq(room.teamId)),
Q.where('team_main', Q.notEq(true))
);
if (result.rooms?.length) {
const teamChannels = result.rooms.map(r => ({
rid: r._id,
if (rooms.length) {
const teamChannels = rooms.map(r => ({
rid: r.id,
name: r.name,
teamId: r.teamId,
alert: r.isLastOwner