From 919542f8fc699917bdad26e8a196e0affdbac94b Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Fri, 4 Jun 2021 15:36:01 +0200 Subject: [PATCH 1/3] Don't assume container node exists when loading bundle Only look for the container node when needed --- src/platform/web/ui/common.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/platform/web/ui/common.js b/src/platform/web/ui/common.js index 9fbafcdf..15a522c7 100644 --- a/src/platform/web/ui/common.js +++ b/src/platform/web/ui/common.js @@ -14,10 +14,13 @@ See the License for the specific language governing permissions and limitations under the License. */ -const container = document.querySelector(".hydrogen"); +let container; export function spinner(t, extraClasses = undefined) { - if (container.classList.contains("legacy")) { + if (container === undefined) { + container = document.querySelector(".hydrogen"); + } + if (container?.classList.contains("legacy")) { return t.div({className: "spinner"}, [ t.div(), t.div(), From bb6905bdcdb991687c91b867f0562f6990e3e1c0 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Fri, 4 Jun 2021 16:05:28 +0200 Subject: [PATCH 2/3] don't assume localEntries exists, as load races with sync.afterSync --- src/matrix/room/timeline/Timeline.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/matrix/room/timeline/Timeline.js b/src/matrix/room/timeline/Timeline.js index eab71255..aa331058 100644 --- a/src/matrix/room/timeline/Timeline.js +++ b/src/matrix/room/timeline/Timeline.js @@ -159,7 +159,9 @@ export class Timeline { // Once the subscription is setup, MappedList will set up the local // relations as needed with _applyAndEmitLocalRelationChange, // so we're not missing anything by bailing out. - if (!this._localEntries.hasSubscriptions) { + // + // _localEntries can also not yet exist + if (!this._localEntries?.hasSubscriptions) { return; } // find any local relations to this new remote event @@ -301,4 +303,4 @@ export function tests() { assert.equal(Array.from(timeline.entries)[0].isRedacting, true); } } -} \ No newline at end of file +} From 7691b28503e4b444b6a6e1dcc5f0037c41a3b105 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Fri, 4 Jun 2021 16:28:08 +0200 Subject: [PATCH 3/3] prevent another race between sync and openTimeline --- src/matrix/room/timeline/Timeline.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/matrix/room/timeline/Timeline.js b/src/matrix/room/timeline/Timeline.js index aa331058..ecba1f2a 100644 --- a/src/matrix/room/timeline/Timeline.js +++ b/src/matrix/room/timeline/Timeline.js @@ -32,7 +32,8 @@ export class Timeline { this._disposables = new Disposables(); this._pendingEvents = pendingEvents; this._clock = clock; - this._remoteEntries = null; + // constructing this early avoid some problem while sync and openTimeline race + this._remoteEntries = new SortedArray((a, b) => a.compare(b)); this._ownMember = null; this._timelineReader = new TimelineReader({ roomId: this._roomId, @@ -96,7 +97,6 @@ export class Timeline { } _setupEntries(timelineEntries) { - this._remoteEntries = new SortedArray((a, b) => a.compare(b)); this._remoteEntries.setManySorted(timelineEntries); if (this._pendingEvents) { this._localEntries = new MappedList(this._pendingEvents, pe => {