From e0aa804971880951b9405415c7ee3379da9d5351 Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Thu, 12 Aug 2021 12:37:47 -0700 Subject: [PATCH] Translate AccountDataStore --- src/matrix/storage/idb/Transaction.js | 2 +- ...ccountDataStore.js => AccountDataStore.ts} | 26 ++++++++++++------- 2 files changed, 18 insertions(+), 10 deletions(-) rename src/matrix/storage/idb/stores/{AccountDataStore.js => AccountDataStore.ts} (57%) diff --git a/src/matrix/storage/idb/Transaction.js b/src/matrix/storage/idb/Transaction.js index 93690017..8b85b795 100644 --- a/src/matrix/storage/idb/Transaction.js +++ b/src/matrix/storage/idb/Transaction.js @@ -33,7 +33,7 @@ import {InboundGroupSessionStore} from "./stores/InboundGroupSessionStore"; import {OutboundGroupSessionStore} from "./stores/OutboundGroupSessionStore"; import {GroupSessionDecryptionStore} from "./stores/GroupSessionDecryptionStore"; import {OperationStore} from "./stores/OperationStore"; -import {AccountDataStore} from "./stores/AccountDataStore.js"; +import {AccountDataStore} from "./stores/AccountDataStore"; export class Transaction { constructor(txn, allowedStoreNames, IDBKeyRange) { diff --git a/src/matrix/storage/idb/stores/AccountDataStore.js b/src/matrix/storage/idb/stores/AccountDataStore.ts similarity index 57% rename from src/matrix/storage/idb/stores/AccountDataStore.js rename to src/matrix/storage/idb/stores/AccountDataStore.ts index 7f22a518..1a7e3e68 100644 --- a/src/matrix/storage/idb/stores/AccountDataStore.js +++ b/src/matrix/storage/idb/stores/AccountDataStore.ts @@ -13,17 +13,25 @@ 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. */ +import {Store} from "../Store" + +interface AccountDataEntry { + type: string + content: { [key : string] : any } +} export class AccountDataStore { - constructor(store) { - this._store = store; - } + private _store: Store - async get(type) { - return await this._store.get(type); - } + constructor(store: Store) { + this._store = store; + } - set(event) { - return this._store.put(event); - } + async get(type: string): Promise { + return await this._store.get(type); + } + + set(event: AccountDataEntry): Promise { + return this._store.put(event); + } }