@@ -1317,26 +1317,28 @@ Room.prototype.addPendingEvent = function(event, txnId) {
1317
1317
* it locally for everyone to read
1318
1318
*/
1319
1319
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
+ } ) ;
1331
1332
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
+ }
1340
1342
}
1341
1343
} ;
1342
1344
0 commit comments