mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 03:25:12 +01:00
Migrate RoomSummaryStore.js to TypeScript.
This commit is contained in:
parent
144e391c82
commit
e284224cc8
@ -18,7 +18,7 @@ import {txnAsPromise} from "./utils";
|
|||||||
import {StorageError} from "../common";
|
import {StorageError} from "../common";
|
||||||
import {Store} from "./Store";
|
import {Store} from "./Store";
|
||||||
import {SessionStore} from "./stores/SessionStore";
|
import {SessionStore} from "./stores/SessionStore";
|
||||||
import {RoomSummaryStore} from "./stores/RoomSummaryStore.js";
|
import {RoomSummaryStore} from "./stores/RoomSummaryStore";
|
||||||
import {InviteStore} from "./stores/InviteStore.js";
|
import {InviteStore} from "./stores/InviteStore.js";
|
||||||
import {TimelineEventStore} from "./stores/TimelineEventStore.js";
|
import {TimelineEventStore} from "./stores/TimelineEventStore.js";
|
||||||
import {TimelineRelationStore} from "./stores/TimelineRelationStore.js";
|
import {TimelineRelationStore} from "./stores/TimelineRelationStore.js";
|
||||||
|
@ -27,31 +27,35 @@ store contains:
|
|||||||
inviteCount
|
inviteCount
|
||||||
joinCount
|
joinCount
|
||||||
*/
|
*/
|
||||||
|
import {Store} from "../Store";
|
||||||
|
import {SummaryData} from "../../../room/RoomSummary";
|
||||||
|
|
||||||
/** Used for both roomSummary and archivedRoomSummary stores */
|
/** Used for both roomSummary and archivedRoomSummary stores */
|
||||||
export class RoomSummaryStore {
|
export class RoomSummaryStore {
|
||||||
constructor(summaryStore) {
|
private _summaryStore: Store<SummaryData>;
|
||||||
|
|
||||||
|
constructor(summaryStore: Store<SummaryData>) {
|
||||||
this._summaryStore = summaryStore;
|
this._summaryStore = summaryStore;
|
||||||
}
|
}
|
||||||
|
|
||||||
getAll() {
|
getAll(): Promise<SummaryData[]> {
|
||||||
return this._summaryStore.selectAll();
|
return this._summaryStore.selectAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
set(summary) {
|
set(summary: SummaryData): Promise<IDBValidKey> {
|
||||||
return this._summaryStore.put(summary);
|
return this._summaryStore.put(summary);
|
||||||
}
|
}
|
||||||
|
|
||||||
get(roomId) {
|
get(roomId: string): Promise<SummaryData | null> {
|
||||||
return this._summaryStore.get(roomId);
|
return this._summaryStore.get(roomId);
|
||||||
}
|
}
|
||||||
|
|
||||||
async has(roomId) {
|
async has(roomId: string): Promise<boolean> {
|
||||||
const fetchedKey = await this._summaryStore.getKey(roomId);
|
const fetchedKey = await this._summaryStore.getKey(roomId);
|
||||||
return roomId === fetchedKey;
|
return roomId === fetchedKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
remove(roomId) {
|
remove(roomId: string): Promise<undefined> {
|
||||||
return this._summaryStore.delete(roomId);
|
return this._summaryStore.delete(roomId);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user