From 47bd18837b88e62192c6b0fe60cabc990e9408be Mon Sep 17 00:00:00 2001 From: Christian King Date: Fri, 18 Feb 2022 09:21:14 -0500 Subject: [PATCH] [FIX] Fix synchronization of removed subscriptions 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. --- 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 56d6c6c42b9..af45e0c3d5b 100644 --- a/app/sagas/rooms.js +++ b/app/sagas/rooms.js @@ -63,9 +63,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));