Skip to content

Commit

Permalink
Prevent pending updates error
Browse files Browse the repository at this point in the history
  • Loading branch information
diegolmello committed Feb 19, 2020
1 parent 2fbc90e commit 90834ad
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/lib/methods/subscriptions/rooms.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,12 @@ export default function subscribeRooms() {
log(e);
}
} else {
// debouncedUpdateSub(data);
debouncedUpdateSub(data);
}
}
if (/rooms/.test(ev)) {
if (type === 'updated' || type === 'inserted') {
// debouncedUpdateRoom(data);
debouncedUpdateRoom(data);
}
}
if (/message/.test(ev)) {
Expand Down
12 changes: 12 additions & 0 deletions app/lib/methods/updateMessages.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,29 @@ export default function updateMessages({ rid, update = [], remove = [] }) {
// Update
msgsToUpdate = msgsToUpdate.map((message) => {
const newMessage = update.find(m => m._id === message.id);
if (message._hasPendingUpdate) {
console.log(message);
return;
}
return message.prepareUpdate(protectedFunction((m) => {
Object.assign(m, newMessage);
}));
});
threadsToUpdate = threadsToUpdate.map((thread) => {
if (thread._hasPendingUpdate) {
console.log(thread);
return;
}
const newThread = allThreads.find(t => t._id === thread.id);
return thread.prepareUpdate(protectedFunction((t) => {
Object.assign(t, newThread);
}));
});
threadMessagesToUpdate = threadMessagesToUpdate.map((threadMessage) => {
if (threadMessage._hasPendingUpdate) {
console.log(threadMessage);
return;
}
const newThreadMessage = allThreadMessages.find(t => t._id === threadMessage.id);
return threadMessage.prepareUpdate(protectedFunction((tm) => {
Object.assign(tm, newThreadMessage);
Expand Down
2 changes: 1 addition & 1 deletion app/lib/rocketchat.js
Original file line number Diff line number Diff line change
Expand Up @@ -1096,7 +1096,7 @@ const RocketChat = {
InteractionManager.runAfterInteractions(() => {
reduxStore.dispatch(setActiveUsers(activeUsers));
});
// this.sdk.subscribe('stream-notify-logged', 'user-status');
this.sdk.subscribe('stream-notify-logged', 'user-status');
return resolve();
}
}
Expand Down

0 comments on commit 90834ad

Please sign in to comment.