[FIX] Room creation error due absence of subscriptions (#11178)

Fixes the following error:

```
Uncaught TypeError: Cannot read property 'name' of undefined
    at roomList.js:127
    at callbacks.js:97
    at Array.reduce (<anonymous>)
    at Object.RocketChat.callbacks.run (callbacks.js:88)
    at Streamer.<anonymous> (cachedCollection.js:340)
    at ev.js:11
    at Array.forEach (<anonymous>)
    at Streamer.emit (ev.js:11)
    at StreamerCentral.<anonymous> (client.js:66)
    at ev.js:11
```
pull/11184/head^2
Tasso Evangelista 8 years ago committed by Guilherme Gazzo
parent 9b0e1980ea
commit add48cae05
  1. 3
      packages/rocketchat-ui-sidenav/client/roomList.js

@ -124,6 +124,9 @@ const mergeSubRoom = (record/*, t*/) => {
RocketChat.callbacks.add('cachedCollection-received-rooms', (room) => {
const sub = RocketChat.models.Subscriptions.findOne({ rid: room._id });
if (!sub) {
return;
}
const $set = {lastMessage : room.lastMessage, lm: room._updatedAt, ...getLowerCaseNames(room, sub.name)};
RocketChat.models.Subscriptions.update({ rid: room._id }, {$set});
});

Loading…
Cancel
Save