invite store

This commit is contained in:
Bruno Windels 2021-04-20 13:02:50 +02:00
parent 03d92b687e
commit 7c4a6fbe4b
4 changed files with 46 additions and 1 deletions

View File

@ -18,6 +18,7 @@ export const STORE_NAMES = Object.freeze([
"session",
"roomState",
"roomSummary",
"invites",
"roomMembers",
"timelineEvents",
"timelineFragments",

View File

@ -19,6 +19,7 @@ import {StorageError} from "../common.js";
import {Store} from "./Store.js";
import {SessionStore} from "./stores/SessionStore.js";
import {RoomSummaryStore} from "./stores/RoomSummaryStore.js";
import {InviteStore} from "./stores/InviteStore.js";
import {TimelineEventStore} from "./stores/TimelineEventStore.js";
import {RoomStateStore} from "./stores/RoomStateStore.js";
import {RoomMemberStore} from "./stores/RoomMemberStore.js";
@ -64,6 +65,10 @@ export class Transaction {
return this._store("roomSummary", idbStore => new RoomSummaryStore(idbStore));
}
get invites() {
return this._store("invites", idbStore => new InviteStore(idbStore));
}
get timelineFragments() {
return this._store("timelineFragments", idbStore => new TimelineFragmentStore(idbStore));
}

View File

@ -11,7 +11,8 @@ export const schema = [
migrateSession,
createE2EEStores,
migrateEncryptionFlag,
createAccountDataStore
createAccountDataStore,
createInviteStore
];
// TODO: how to deal with git merge conflicts of this array?
@ -103,3 +104,8 @@ async function migrateEncryptionFlag(db, txn) {
function createAccountDataStore(db) {
db.createObjectStore("accountData", {keyPath: "type"});
}
// v7
function createInviteStore(db) {
db.createObjectStore("invites", {keyPath: "roomId"});
}

View File

@ -0,0 +1,33 @@
/*
Copyright 2021 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
export class InviteStore {
constructor(inviteStore) {
this._inviteStore = inviteStore;
}
getAll() {
return this._inviteStore.selectAll();
}
set(invite) {
return this._inviteStore.put(invite);
}
remove(roomId) {
this._store.delete(roomId);
}
}