From 58c9e98e49cc652a8546a17db3a0d7eca16c9452 Mon Sep 17 00:00:00 2001 From: Diego Mello Date: Fri, 11 Mar 2022 11:19:23 -0300 Subject: [PATCH] [FIX] Fix synchronization of removed subscriptions (#3768) When a subscription is removed from the server via another client, when the mobile app is relaunched the subscriptions were not being removed properly. Changed the logic to use the subscriptionResult.remove array from the server and the _id property to fix. Co-authored-by: Christian King --- app/sagas/rooms.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/sagas/rooms.js b/app/sagas/rooms.js index 28cb12fc0..4787c2714 100644 --- a/app/sagas/rooms.js +++ b/app/sagas/rooms.js @@ -51,9 +51,9 @@ const handleRoomsRequest = function* handleRoomsRequest({ params }) { const subCollection = db.get('subscriptions'); const messagesCollection = db.get('messages'); - const subsIds = subscriptions.map(sub => sub.rid).concat(roomsResult.remove.map(room => room._id)); + const subsIds = subscriptions.map(sub => sub._id).concat(subscriptionsResult.remove.map(sub => sub._id)); if (subsIds.length) { - const existingSubs = yield subCollection.query(Q.where('id', Q.oneOf(subsIds))).fetch(); + const existingSubs = yield subCollection.query(Q.where('_id', Q.oneOf(subsIds))).fetch(); const subsToUpdate = existingSubs.filter(i1 => subscriptions.find(i2 => i1._id === i2._id)); const subsToCreate = subscriptions.filter(i1 => !existingSubs.find(i2 => i1._id === i2._id)); const subsToDelete = existingSubs.filter(i1 => !subscriptions.find(i2 => i1._id === i2._id));