forked from mystiq/hydrogen-web
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;
|
let decryptPreparation;
|
||||||
if (roomEncryption) {
|
if (roomEncryption) {
|
||||||
const events = roomResponse?.timeline?.events;
|
// also look for events in timeline here
|
||||||
if (Array.isArray(events)) {
|
let events = roomResponse?.timeline?.events || [];
|
||||||
|
if (events.length) {
|
||||||
const eventsToDecrypt = events.filter(event => {
|
const eventsToDecrypt = events.filter(event => {
|
||||||
return event?.type === EVENT_ENCRYPTED_TYPE;
|
return event?.type === EVENT_ENCRYPTED_TYPE;
|
||||||
});
|
});
|
||||||
|
|
|
@ -167,7 +167,7 @@ export class SyncWriter {
|
||||||
}
|
}
|
||||||
|
|
||||||
async _writeTimeline(entries, timeline, currentKey, memberChanges, txn, log) {
|
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
|
// only create a fragment when we will really write an event
|
||||||
currentKey = await this._ensureLiveFragment(currentKey, entries, timeline, txn, log);
|
currentKey = await this._ensureLiveFragment(currentKey, entries, timeline, txn, log);
|
||||||
const events = deduplicateEvents(timeline.events);
|
const events = deduplicateEvents(timeline.events);
|
||||||
|
|
Loading…
Reference in a new issue