diff --git a/src/matrix/room/timeline/entries/BaseEntry.js b/src/matrix/room/timeline/entries/BaseEntry.ts similarity index 80% rename from src/matrix/room/timeline/entries/BaseEntry.js rename to src/matrix/room/timeline/entries/BaseEntry.ts index ae3ddf05..c592ecb6 100644 --- a/src/matrix/room/timeline/entries/BaseEntry.js +++ b/src/matrix/room/timeline/entries/BaseEntry.ts @@ -18,20 +18,26 @@ limitations under the License. import {EventKey} from "../EventKey.js"; export const PENDING_FRAGMENT_ID = Number.MAX_SAFE_INTEGER; +interface FragmentIdComparer { + compare: (a: number, b: number) => number +} + export class BaseEntry { - constructor(fragmentIdComparer) { + protected _fragmentIdComparer: FragmentIdComparer + + constructor(fragmentIdComparer: FragmentIdComparer) { this._fragmentIdComparer = fragmentIdComparer; } - get fragmentId() { + get fragmentId(): number { throw new Error("unimplemented"); } - get entryIndex() { + get entryIndex(): number { throw new Error("unimplemented"); } - compare(otherEntry) { + compare(otherEntry: BaseEntry): number { if (this.fragmentId === otherEntry.fragmentId) { return this.entryIndex - otherEntry.entryIndex; } else if (this.fragmentId === PENDING_FRAGMENT_ID) { @@ -44,9 +50,9 @@ export class BaseEntry { } } - asEventKey() { + asEventKey(): EventKey { return new EventKey(this.fragmentId, this.entryIndex); } - updateFrom() {} + updateFrom(other: BaseEntry) {} } diff --git a/src/matrix/room/timeline/entries/BaseEventEntry.js b/src/matrix/room/timeline/entries/BaseEventEntry.js index 2e681104..7eb0fc94 100644 --- a/src/matrix/room/timeline/entries/BaseEventEntry.js +++ b/src/matrix/room/timeline/entries/BaseEventEntry.js @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -import {BaseEntry} from "./BaseEntry.js"; +import {BaseEntry} from "./BaseEntry"; import {REDACTION_TYPE} from "../../common.js"; import {createAnnotation, ANNOTATION_RELATION_TYPE, getRelationFromContent} from "../relations.js"; import {PendingAnnotation} from "../PendingAnnotation.js"; diff --git a/src/matrix/room/timeline/entries/FragmentBoundaryEntry.js b/src/matrix/room/timeline/entries/FragmentBoundaryEntry.js index 0eb2a5b6..3d4bd67b 100644 --- a/src/matrix/room/timeline/entries/FragmentBoundaryEntry.js +++ b/src/matrix/room/timeline/entries/FragmentBoundaryEntry.js @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -import {BaseEntry} from "./BaseEntry.js"; +import {BaseEntry} from "./BaseEntry"; import {Direction} from "../Direction.js"; import {isValidFragmentId} from "../common.js"; import {KeyLimits} from "../../../storage/common.js"; diff --git a/src/matrix/room/timeline/entries/PendingEventEntry.js b/src/matrix/room/timeline/entries/PendingEventEntry.js index 742bff49..4bc3c47e 100644 --- a/src/matrix/room/timeline/entries/PendingEventEntry.js +++ b/src/matrix/room/timeline/entries/PendingEventEntry.js @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -import {PENDING_FRAGMENT_ID} from "./BaseEntry.js"; +import {PENDING_FRAGMENT_ID} from "./BaseEntry"; import {BaseEventEntry} from "./BaseEventEntry.js"; export class PendingEventEntry extends BaseEventEntry {