From 053dcf39a5fb4891cd235336c4a4a87b10025e17 Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Tue, 7 Dec 2021 16:01:30 +0530 Subject: [PATCH] Use NonPersistedEventEntry --- src/matrix/room/BaseRoom.js | 3 +- .../entries/NonPersistedEventEntry.js | 28 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 src/matrix/room/timeline/entries/NonPersistedEventEntry.js diff --git a/src/matrix/room/BaseRoom.js b/src/matrix/room/BaseRoom.js index 1c1e3720..9e47a7d8 100644 --- a/src/matrix/room/BaseRoom.js +++ b/src/matrix/room/BaseRoom.js @@ -30,6 +30,7 @@ import {DecryptionSource} from "../e2ee/common.js"; import {ensureLogItem} from "../../logging/utils"; import {PowerLevels} from "./PowerLevels.js"; import {RetainedObservableValue} from "../../observable/ObservableValue"; +import {NonPersistedEventEntry} from "./timeline/entries/NonPersistedEventEntry"; const EVENT_ENCRYPTED_TYPE = "m.room.encrypted"; @@ -570,7 +571,7 @@ export class BaseRoom extends EventEmitter { displayName: member.content.displayname, avatarUrl: member.content.avatar_url }; - return new EventEntry(entry, this._fragmentIdComparer); + return new NonPersistedEventEntry(entry, this._fragmentIdComparer); } diff --git a/src/matrix/room/timeline/entries/NonPersistedEventEntry.js b/src/matrix/room/timeline/entries/NonPersistedEventEntry.js new file mode 100644 index 00000000..f3bae9d2 --- /dev/null +++ b/src/matrix/room/timeline/entries/NonPersistedEventEntry.js @@ -0,0 +1,28 @@ +/* +Copyright 2021 The Matrix.org Foundation C.I.C. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +import {EventEntry} from "./EventEntry.js"; + +// EventEntry but without the two properties that are populated via SyncWriter +export class NonPersistedEventEntry extends EventEntry { + get fragmentId() { + throw new Error("Cannot access fragmentId for non-persisted EventEntry"); + } + + get entryIndex() { + throw new Error("Cannot access entryIndex for non-persisted EventEntry"); + } +}