[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 <cking@vonix.io>
This commit is contained in:
parent
65c9aec2b4
commit
58c9e98e49
|
@ -51,9 +51,9 @@ const handleRoomsRequest = function* handleRoomsRequest({ params }) {
|
||||||
const subCollection = db.get('subscriptions');
|
const subCollection = db.get('subscriptions');
|
||||||
const messagesCollection = db.get('messages');
|
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) {
|
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 subsToUpdate = existingSubs.filter(i1 => subscriptions.find(i2 => i1._id === i2._id));
|
||||||
const subsToCreate = subscriptions.filter(i1 => !existingSubs.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));
|
const subsToDelete = existingSubs.filter(i1 => !subscriptions.find(i2 => i1._id === i2._id));
|
||||||
|
|
Loading…
Reference in New Issue