mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-22 19:14:52 +01:00
convert EventKey to ts
This commit is contained in:
parent
85c8415acd
commit
7cb686ce8e
@ -15,20 +15,22 @@ limitations under the License.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {KeyLimits} from "../../storage/common";
|
import {KeyLimits} from "../../storage/common";
|
||||||
|
import {Direction} from "./Direction";
|
||||||
|
|
||||||
// key for events in the timelineEvents store
|
// key for events in the timelineEvents store
|
||||||
export class EventKey {
|
export class EventKey {
|
||||||
constructor(fragmentId, eventIndex) {
|
constructor(
|
||||||
this.fragmentId = fragmentId;
|
public readonly fragmentId: number,
|
||||||
this.eventIndex = eventIndex;
|
public readonly eventIndex: number
|
||||||
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
nextFragmentKey() {
|
nextFragmentKey(): EventKey {
|
||||||
// could take MIN_EVENT_INDEX here if it can't be paged back
|
// could take MIN_EVENT_INDEX here if it can't be paged back
|
||||||
return new EventKey(this.fragmentId + 1, KeyLimits.middleStorageKey);
|
return new EventKey(this.fragmentId + 1, KeyLimits.middleStorageKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
nextKeyForDirection(direction) {
|
nextKeyForDirection(direction: Direction): EventKey {
|
||||||
if (direction.isForward) {
|
if (direction.isForward) {
|
||||||
return this.nextKey();
|
return this.nextKey();
|
||||||
} else {
|
} else {
|
||||||
@ -36,35 +38,35 @@ export class EventKey {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
previousKey() {
|
previousKey(): EventKey {
|
||||||
return new EventKey(this.fragmentId, this.eventIndex - 1);
|
return new EventKey(this.fragmentId, this.eventIndex - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
nextKey() {
|
nextKey(): EventKey {
|
||||||
return new EventKey(this.fragmentId, this.eventIndex + 1);
|
return new EventKey(this.fragmentId, this.eventIndex + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static get maxKey() {
|
static get maxKey(): EventKey {
|
||||||
return new EventKey(KeyLimits.maxStorageKey, KeyLimits.maxStorageKey);
|
return new EventKey(KeyLimits.maxStorageKey, KeyLimits.maxStorageKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
static get minKey() {
|
static get minKey(): EventKey {
|
||||||
return new EventKey(KeyLimits.minStorageKey, KeyLimits.minStorageKey);
|
return new EventKey(KeyLimits.minStorageKey, KeyLimits.minStorageKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
static get defaultLiveKey() {
|
static get defaultLiveKey(): EventKey {
|
||||||
return EventKey.defaultFragmentKey(KeyLimits.minStorageKey);
|
return EventKey.defaultFragmentKey(KeyLimits.minStorageKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
static defaultFragmentKey(fragmentId) {
|
static defaultFragmentKey(fragmentId: number): EventKey {
|
||||||
return new EventKey(fragmentId, KeyLimits.middleStorageKey);
|
return new EventKey(fragmentId, KeyLimits.middleStorageKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
toString() {
|
toString(): string {
|
||||||
return `[${this.fragmentId}/${this.eventIndex}]`;
|
return `[${this.fragmentId}/${this.eventIndex}]`;
|
||||||
}
|
}
|
||||||
|
|
||||||
equals(other) {
|
equals(other: EventKey): boolean {
|
||||||
return this.fragmentId === other?.fragmentId && this.eventIndex === other?.eventIndex;
|
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.
|
//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;
|
export const PENDING_FRAGMENT_ID = Number.MAX_SAFE_INTEGER;
|
||||||
|
|
||||||
interface FragmentIdComparer {
|
interface FragmentIdComparer {
|
||||||
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {EventKey} from "../EventKey.js";
|
import {EventKey} from "../EventKey";
|
||||||
import {EventEntry} from "../entries/EventEntry.js";
|
import {EventEntry} from "../entries/EventEntry.js";
|
||||||
import {createEventEntry, directionalAppend} from "./common.js";
|
import {createEventEntry, directionalAppend} from "./common.js";
|
||||||
import {RoomMember, EVENT_TYPE as MEMBER_EVENT_TYPE} from "../../members/RoomMember.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.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {EventKey} from "../EventKey.js";
|
import {EventKey} from "../EventKey";
|
||||||
import {EventEntry} from "../entries/EventEntry.js";
|
import {EventEntry} from "../entries/EventEntry.js";
|
||||||
import {FragmentBoundaryEntry} from "../entries/FragmentBoundaryEntry.js";
|
import {FragmentBoundaryEntry} from "../entries/FragmentBoundaryEntry.js";
|
||||||
import {createEventEntry} from "./common.js";
|
import {createEventEntry} from "./common.js";
|
||||||
|
@ -14,12 +14,19 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
<<<<<<< HEAD:src/matrix/storage/idb/stores/TimelineEventStore.ts
|
||||||
import {EventKey} from "../../../room/timeline/EventKey.js";
|
import {EventKey} from "../../../room/timeline/EventKey.js";
|
||||||
import { StorageError } from "../../common";
|
import { StorageError } from "../../common";
|
||||||
import { encodeUint32 } from "../utils";
|
import { encodeUint32 } from "../utils";
|
||||||
import {KeyLimits} from "../../common";
|
import {KeyLimits} from "../../common";
|
||||||
import {Store} from "../Store";
|
import {Store} from "../Store";
|
||||||
import {TimelineEvent, StateEvent} from "../../types";
|
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 {
|
interface Annotation {
|
||||||
count: number;
|
count: number;
|
||||||
|
Loading…
Reference in New Issue
Block a user