From 742ab280992941498360e367ac64f4935e18fb57 Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Thu, 12 Aug 2021 12:37:47 -0700 Subject: [PATCH] Migrate AccountDataStore.js to TypeScript. --- src/matrix/storage/idb/Transaction.js | 2 +- ...ccountDataStore.js => AccountDataStore.ts} | 27 ++++++++++++------- 2 files changed, 19 insertions(+), 10 deletions(-) rename src/matrix/storage/idb/stores/{AccountDataStore.js => AccountDataStore.ts} (55%) diff --git a/src/matrix/storage/idb/Transaction.js b/src/matrix/storage/idb/Transaction.js index 7d5f8af9..23037195 100644 --- a/src/matrix/storage/idb/Transaction.js +++ b/src/matrix/storage/idb/Transaction.js @@ -33,7 +33,7 @@ import {InboundGroupSessionStore} from "./stores/InboundGroupSessionStore.js"; 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 55% rename from src/matrix/storage/idb/stores/AccountDataStore.js rename to src/matrix/storage/idb/stores/AccountDataStore.ts index 7f22a518..7538c53e 100644 --- a/src/matrix/storage/idb/stores/AccountDataStore.js +++ b/src/matrix/storage/idb/stores/AccountDataStore.ts @@ -13,17 +13,26 @@ 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"; +import {Content} from "../../types"; + +interface AccountDataEntry { + type: string; + content: Content; +} 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); + } }