Skip to content

Commit

Permalink
Merge pull request #8314 from szluohua/synchronizing
Browse files Browse the repository at this point in the history
[FIX] After deleting the room, cache is not synchronizing
  • Loading branch information
rodrigok authored Sep 29, 2017
2 parents 5abb1d2 + 1b13e0c commit 70aee61
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/rocketchat-lib/client/lib/cachedCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ class CachedCollection {
this.log('record received', t, record);
if (t === 'removed') {
this.collection.remove(record._id);
RoomManager.close(record.t+record.name);
} else {
delete record.$loki;
this.collection.upsert({ _id: record._id }, _.omit(record, '_id'));
Expand Down
6 changes: 6 additions & 0 deletions packages/rocketchat-ui/client/views/app/room.js
Original file line number Diff line number Diff line change
Expand Up @@ -954,4 +954,10 @@ Template.room.onRendered(function() {
newMessage.classList.remove('not');
}
});
Tracker.autorun(function() {
const subRoom = ChatSubscription.findOne({rid:template.data._id});
if (!subRoom) {
FlowRouter.go('home');
}
});
});
2 changes: 1 addition & 1 deletion server/publications/room.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ RocketChat.models.Rooms.cache.on('sync', (type, room/*, diff*/) => {
});

RocketChat.models.Subscriptions.on('changed', (type, subscription/*, diff*/) => {
if (type === 'inserted') {
if (type === 'inserted' || type === 'removed') {
const room = RocketChat.models.Rooms.findOneById(subscription.rid);
if (room) {
RocketChat.Notifications.notifyUserInThisInstance(subscription.u._id, 'rooms-changed', type, roomMap({_room: room}));
Expand Down

0 comments on commit 70aee61

Please sign in to comment.