From d4d7adc7fc1ab5328c4ef918afa359daadd47ca5 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 4 May 2021 13:34:42 +0200 Subject: [PATCH] add archivedRoomSummary store --- src/matrix/Sync.js | 1 + src/matrix/storage/common.js | 1 + src/matrix/storage/idb/Transaction.js | 4 ++++ src/matrix/storage/idb/schema.js | 8 +++++++- src/matrix/storage/idb/stores/RoomSummaryStore.js | 6 ++++++ 5 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/matrix/Sync.js b/src/matrix/Sync.js index a99c0938..de1099e4 100644 --- a/src/matrix/Sync.js +++ b/src/matrix/Sync.js @@ -316,6 +316,7 @@ export class Sync { return this._storage.readWriteTxn([ storeNames.session, storeNames.roomSummary, + storeNames.archivedRoomSummary, storeNames.invites, storeNames.roomState, storeNames.roomMembers, diff --git a/src/matrix/storage/common.js b/src/matrix/storage/common.js index 438cf6b3..bd477cbd 100644 --- a/src/matrix/storage/common.js +++ b/src/matrix/storage/common.js @@ -18,6 +18,7 @@ export const STORE_NAMES = Object.freeze([ "session", "roomState", "roomSummary", + "archivedRoomSummary", "invites", "roomMembers", "timelineEvents", diff --git a/src/matrix/storage/idb/Transaction.js b/src/matrix/storage/idb/Transaction.js index 162f821f..d497077b 100644 --- a/src/matrix/storage/idb/Transaction.js +++ b/src/matrix/storage/idb/Transaction.js @@ -64,6 +64,10 @@ export class Transaction { get roomSummary() { return this._store("roomSummary", idbStore => new RoomSummaryStore(idbStore)); } + + get archivedRoomSummary() { + return this._store("archivedRoomSummary", idbStore => new RoomSummaryStore(idbStore)); + } get invites() { return this._store("invites", idbStore => new InviteStore(idbStore)); diff --git a/src/matrix/storage/idb/schema.js b/src/matrix/storage/idb/schema.js index 7cf100aa..f0c052ea 100644 --- a/src/matrix/storage/idb/schema.js +++ b/src/matrix/storage/idb/schema.js @@ -12,7 +12,8 @@ export const schema = [ createE2EEStores, migrateEncryptionFlag, createAccountDataStore, - createInviteStore + createInviteStore, + createArchivedRoomSummaryStore, ]; // TODO: how to deal with git merge conflicts of this array? @@ -109,3 +110,8 @@ function createAccountDataStore(db) { function createInviteStore(db) { db.createObjectStore("invites", {keyPath: "roomId"}); } + +// v8 +function createArchivedRoomSummaryStore(db) { + db.createObjectStore("archivedRoomSummary", {keyPath: "roomId"}); +} \ No newline at end of file diff --git a/src/matrix/storage/idb/stores/RoomSummaryStore.js b/src/matrix/storage/idb/stores/RoomSummaryStore.js index 1264657e..a445cd99 100644 --- a/src/matrix/storage/idb/stores/RoomSummaryStore.js +++ b/src/matrix/storage/idb/stores/RoomSummaryStore.js @@ -27,6 +27,8 @@ store contains: inviteCount joinCount */ + +/** Used for both roomSummary and archivedRoomSummary stores */ export class RoomSummaryStore { constructor(summaryStore) { this._summaryStore = summaryStore; @@ -39,4 +41,8 @@ export class RoomSummaryStore { set(summary) { return this._summaryStore.put(summary); } + + remove(roomId) { + return this._summaryStore.delete(roomId); + } }