Skip to content

Commit 2666a27

Browse files
committed
fix tests when pendingEventsList does not exist
1 parent 466f749 commit 2666a27

File tree

1 file changed

+21
-19
lines changed

1 file changed

+21
-19
lines changed

src/models/room.js

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1317,26 +1317,28 @@ Room.prototype.addPendingEvent = function(event, txnId) {
13171317
* it locally for everyone to read
13181318
*/
13191319
Room.prototype._savePendingEvents = function() {
1320-
const pendingEvents = this._pendingEventList.map(event => {
1321-
return {
1322-
...event.event,
1323-
txn_id: event.getTxnId(),
1324-
};
1325-
}).filter(event => {
1326-
// Filter out the unencrypted messages if the room is encrypted
1327-
const isEventEncrypted = event.type === "m.room.encrypted";
1328-
const isRoomEncrypted = this._client.isRoomEncrypted(this.roomId);
1329-
return isEventEncrypted || !isRoomEncrypted;
1330-
});
1320+
if (this._pendingEventList) {
1321+
const pendingEvents = this._pendingEventList.map(event => {
1322+
return {
1323+
...event.event,
1324+
txn_id: event.getTxnId(),
1325+
};
1326+
}).filter(event => {
1327+
// Filter out the unencrypted messages if the room is encrypted
1328+
const isEventEncrypted = event.type === "m.room.encrypted";
1329+
const isRoomEncrypted = this._client.isRoomEncrypted(this.roomId);
1330+
return isEventEncrypted || !isRoomEncrypted;
1331+
});
13311332

1332-
const { store } = this._client._sessionStore;
1333-
if (this._pendingEventList.length > 0) {
1334-
store.setItem(
1335-
pendingEventsKey(this.roomId),
1336-
JSON.stringify(pendingEvents),
1337-
);
1338-
} else {
1339-
store.removeItem(pendingEventsKey(this.roomId));
1333+
const { store } = this._client._sessionStore;
1334+
if (this._pendingEventList.length > 0) {
1335+
store.setItem(
1336+
pendingEventsKey(this.roomId),
1337+
JSON.stringify(pendingEvents),
1338+
);
1339+
} else {
1340+
store.removeItem(pendingEventsKey(this.roomId));
1341+
}
13401342
}
13411343
};
13421344

0 commit comments

Comments
 (0)