forked from mystiq/hydrogen-web
invite store
This commit is contained in:
parent
03d92b687e
commit
7c4a6fbe4b
4 changed files with 46 additions and 1 deletions
|
@ -18,6 +18,7 @@ export const STORE_NAMES = Object.freeze([
|
|||
"session",
|
||||
"roomState",
|
||||
"roomSummary",
|
||||
"invites",
|
||||
"roomMembers",
|
||||
"timelineEvents",
|
||||
"timelineFragments",
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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"});
|
||||
}
|
||||
|
|
33
src/matrix/storage/idb/stores/InviteStore.js
Normal file
33
src/matrix/storage/idb/stores/InviteStore.js
Normal 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);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue