convert EventKey to ts
This commit is contained in:
parent
85c8415acd
commit
7cb686ce8e
5 changed files with 25 additions and 16 deletions
|
@ -15,20 +15,22 @@ limitations under the License.
|
|||
*/
|
||||
|
||||
import {KeyLimits} from "../../storage/common";
|
||||
import {Direction} from "./Direction";
|
||||
|
||||
// key for events in the timelineEvents store
|
||||
export class EventKey {
|
||||
constructor(fragmentId, eventIndex) {
|
||||
this.fragmentId = fragmentId;
|
||||
this.eventIndex = eventIndex;
|
||||
constructor(
|
||||
public readonly fragmentId: number,
|
||||
public readonly eventIndex: number
|
||||
) {
|
||||
}
|
||||
|
||||
nextFragmentKey() {
|
||||
nextFragmentKey(): EventKey {
|
||||
// could take MIN_EVENT_INDEX here if it can't be paged back
|
||||
return new EventKey(this.fragmentId + 1, KeyLimits.middleStorageKey);
|
||||
}
|
||||
|
||||
nextKeyForDirection(direction) {
|
||||
nextKeyForDirection(direction: Direction): EventKey {
|
||||
if (direction.isForward) {
|
||||
return this.nextKey();
|
||||
} else {
|
||||
|
@ -36,35 +38,35 @@ export class EventKey {
|
|||
}
|
||||
}
|
||||
|
||||
previousKey() {
|
||||
previousKey(): EventKey {
|
||||
return new EventKey(this.fragmentId, this.eventIndex - 1);
|
||||
}
|
||||
|
||||
nextKey() {
|
||||
nextKey(): EventKey {
|
||||
return new EventKey(this.fragmentId, this.eventIndex + 1);
|
||||
}
|
||||
|
||||
static get maxKey() {
|
||||
static get maxKey(): EventKey {
|
||||
return new EventKey(KeyLimits.maxStorageKey, KeyLimits.maxStorageKey);
|
||||
}
|
||||
|
||||
static get minKey() {
|
||||
static get minKey(): EventKey {
|
||||
return new EventKey(KeyLimits.minStorageKey, KeyLimits.minStorageKey);
|
||||
}
|
||||
|
||||
static get defaultLiveKey() {
|
||||
static get defaultLiveKey(): EventKey {
|
||||
return EventKey.defaultFragmentKey(KeyLimits.minStorageKey);
|
||||
}
|
||||
|
||||
static defaultFragmentKey(fragmentId) {
|
||||
static defaultFragmentKey(fragmentId: number): EventKey {
|
||||
return new EventKey(fragmentId, KeyLimits.middleStorageKey);
|
||||
}
|
||||
|
||||
toString() {
|
||||
toString(): string {
|
||||
return `[${this.fragmentId}/${this.eventIndex}]`;
|
||||
}
|
||||
|
||||
equals(other) {
|
||||
equals(other: EventKey): boolean {
|
||||
return this.fragmentId === other?.fragmentId && this.eventIndex === other?.eventIndex;
|
||||
}
|
||||
}
|
|
@ -15,7 +15,7 @@ limitations under the License.
|
|||
*/
|
||||
|
||||
//entries can be sorted, first by fragment, then by entry index.
|
||||
import {EventKey} from "../EventKey.js";
|
||||
import {EventKey} from "../EventKey";
|
||||
export const PENDING_FRAGMENT_ID = Number.MAX_SAFE_INTEGER;
|
||||
|
||||
interface FragmentIdComparer {
|
||||
|
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
import {EventKey} from "../EventKey.js";
|
||||
import {EventKey} from "../EventKey";
|
||||
import {EventEntry} from "../entries/EventEntry.js";
|
||||
import {createEventEntry, directionalAppend} from "./common.js";
|
||||
import {RoomMember, EVENT_TYPE as MEMBER_EVENT_TYPE} from "../../members/RoomMember.js";
|
||||
|
|
|
@ -15,7 +15,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
import {EventKey} from "../EventKey.js";
|
||||
import {EventKey} from "../EventKey";
|
||||
import {EventEntry} from "../entries/EventEntry.js";
|
||||
import {FragmentBoundaryEntry} from "../entries/FragmentBoundaryEntry.js";
|
||||
import {createEventEntry} from "./common.js";
|
||||
|
|
|
@ -14,12 +14,19 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
<<<<<<< HEAD:src/matrix/storage/idb/stores/TimelineEventStore.ts
|
||||
import {EventKey} from "../../../room/timeline/EventKey.js";
|
||||
import { StorageError } from "../../common";
|
||||
import { encodeUint32 } from "../utils";
|
||||
import {KeyLimits} from "../../common";
|
||||
import {Store} from "../Store";
|
||||
import {TimelineEvent, StateEvent} from "../../types";
|
||||
=======
|
||||
import {EventKey} from "../../../room/timeline/EventKey";
|
||||
import { StorageError } from "../../common.js";
|
||||
import { encodeUint32 } from "../utils.js";
|
||||
import {KeyLimits} from "../../common.js";
|
||||
>>>>>>> b01c3283 (convert EventKey to ts):src/matrix/storage/idb/stores/TimelineEventStore.js
|
||||
|
||||
interface Annotation {
|
||||
count: number;
|
||||
|
|
Reference in a new issue