convert Direction to ts

This commit is contained in:
Bruno Windels 2021-08-18 18:21:43 +02:00
parent ed082c9869
commit 85c8415acd
4 changed files with 11 additions and 16 deletions

View file

@ -15,34 +15,29 @@ limitations under the License.
*/
export class Direction {
constructor(isForward) {
this._isForward = isForward;
constructor(public readonly isForward: boolean) {
}
get isForward() {
return this._isForward;
}
get isBackward() {
get isBackward(): boolean {
return !this.isForward;
}
asApiString() {
asApiString(): string {
return this.isForward ? "f" : "b";
}
reverse() {
reverse(): Direction {
return this.isForward ? Direction.Backward : Direction.Forward
}
static get Forward() {
static get Forward(): Direction {
return _forward;
}
static get Backward() {
static get Backward(): Direction {
return _backward;
}
}
const _forward = Object.freeze(new Direction(true));
const _backward = Object.freeze(new Direction(false));
const _forward = new Direction(true);
const _backward = new Direction(false);

View file

@ -17,7 +17,7 @@ limitations under the License.
import {SortedArray, AsyncMappedList, ConcatList, ObservableArray} from "../../../observable/index.js";
import {Disposables} from "../../../utils/Disposables.js";
import {Direction} from "./Direction.js";
import {Direction} from "./Direction";
import {TimelineReader} from "./persistence/TimelineReader.js";
import {PendingEventEntry} from "./entries/PendingEventEntry.js";
import {RoomMember} from "../members/RoomMember.js";

View file

@ -15,7 +15,7 @@ limitations under the License.
*/
import {BaseEntry} from "./BaseEntry";
import {Direction} from "../Direction.js";
import {Direction} from "../Direction";
import {isValidFragmentId} from "../common.js";
import {KeyLimits} from "../../../storage/common";

View file

@ -15,7 +15,7 @@ limitations under the License.
*/
import {directionalConcat, directionalAppend} from "./common.js";
import {Direction} from "../Direction.js";
import {Direction} from "../Direction";
import {EventEntry} from "../entries/EventEntry.js";
import {FragmentBoundaryEntry} from "../entries/FragmentBoundaryEntry.js";