Add initial translation of RoomSummaryStore.js

This commit is contained in:
Danila Fedorin 2021-08-10 16:28:47 -07:00
parent 5177c35d0d
commit f8613e9e96
3 changed files with 23 additions and 19 deletions

View file

@ -94,7 +94,7 @@ export class QueryTarget<T> {
return this._selectWhile(range, predicate, "prev");
}
async selectAll(range: IDBKeyRange, direction: IDBCursorDirection): Promise<T[]> {
async selectAll(range?: IDBKeyRange, direction?: IDBCursorDirection): Promise<T[]> {
const cursor = this._openCursor(range, direction);
const results: T[] = [];
await iterateCursor<T>(cursor, (value) => {

View file

@ -18,7 +18,7 @@ import {txnAsPromise} from "./utils";
import {StorageError} from "../common";
import {Store} from "./Store";
import {SessionStore} from "./stores/SessionStore";
import {RoomSummaryStore} from "./stores/RoomSummaryStore.js";
import {RoomSummaryStore} from "./stores/RoomSummaryStore";
import {InviteStore} from "./stores/InviteStore.js";
import {TimelineEventStore} from "./stores/TimelineEventStore.js";
import {TimelineRelationStore} from "./stores/TimelineRelationStore.js";

View file

@ -27,10 +27,14 @@ store contains:
inviteCount
joinCount
*/
import {Store} from "../Store"
import {SummaryData} from "../../../room/RoomSummary"
/** Used for both roomSummary and archivedRoomSummary stores */
export class RoomSummaryStore {
constructor(summaryStore) {
private _summaryStore: Store<SummaryData>
constructor(summaryStore: Store<SummaryData>) {
this._summaryStore = summaryStore;
}
@ -38,20 +42,20 @@ export class RoomSummaryStore {
return this._summaryStore.selectAll();
}
set(summary) {
set(summary: SummaryData) {
return this._summaryStore.put(summary);
}
get(roomId) {
get(roomId: string) {
return this._summaryStore.get(roomId);
}
async has(roomId) {
async has(roomId: string) {
const fetchedKey = await this._summaryStore.getKey(roomId);
return roomId === fetchedKey;
}
remove(roomId) {
remove(roomId: string) {
return this._summaryStore.delete(roomId);
}
}