don't break on empty room sync response
This commit is contained in:
parent
8a39c16a38
commit
061e7abd50
2 changed files with 4 additions and 3 deletions
|
@ -191,8 +191,9 @@ export class Room extends EventEmitter {
|
|||
|
||||
let decryptPreparation;
|
||||
if (roomEncryption) {
|
||||
const events = roomResponse?.timeline?.events;
|
||||
if (Array.isArray(events)) {
|
||||
// also look for events in timeline here
|
||||
let events = roomResponse?.timeline?.events || [];
|
||||
if (events.length) {
|
||||
const eventsToDecrypt = events.filter(event => {
|
||||
return event?.type === EVENT_ENCRYPTED_TYPE;
|
||||
});
|
||||
|
|
|
@ -167,7 +167,7 @@ export class SyncWriter {
|
|||
}
|
||||
|
||||
async _writeTimeline(entries, timeline, currentKey, memberChanges, txn, log) {
|
||||
if (Array.isArray(timeline.events) && timeline.events.length) {
|
||||
if (Array.isArray(timeline?.events) && timeline.events.length) {
|
||||
// only create a fragment when we will really write an event
|
||||
currentKey = await this._ensureLiveFragment(currentKey, entries, timeline, txn, log);
|
||||
const events = deduplicateEvents(timeline.events);
|
||||
|
|
Reference in a new issue