From 8d44df83c42ccf664b26ae63c71d77a29a813293 Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Wed, 11 Aug 2021 16:38:37 -0700 Subject: [PATCH] Migrate UserIdentityStore to TypeScript --- src/matrix/storage/idb/Transaction.js | 2 +- ...rIdentityStore.js => UserIdentityStore.ts} | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) rename src/matrix/storage/idb/stores/{UserIdentityStore.js => UserIdentityStore.ts} (63%) diff --git a/src/matrix/storage/idb/Transaction.js b/src/matrix/storage/idb/Transaction.js index f66e04dc..f1d0eb3b 100644 --- a/src/matrix/storage/idb/Transaction.js +++ b/src/matrix/storage/idb/Transaction.js @@ -26,7 +26,7 @@ import {RoomStateStore} from "./stores/RoomStateStore"; import {RoomMemberStore} from "./stores/RoomMemberStore"; import {TimelineFragmentStore} from "./stores/TimelineFragmentStore"; import {PendingEventStore} from "./stores/PendingEventStore"; -import {UserIdentityStore} from "./stores/UserIdentityStore.js"; +import {UserIdentityStore} from "./stores/UserIdentityStore"; import {DeviceIdentityStore} from "./stores/DeviceIdentityStore.js"; import {OlmSessionStore} from "./stores/OlmSessionStore.js"; import {InboundGroupSessionStore} from "./stores/InboundGroupSessionStore.js"; diff --git a/src/matrix/storage/idb/stores/UserIdentityStore.js b/src/matrix/storage/idb/stores/UserIdentityStore.ts similarity index 63% rename from src/matrix/storage/idb/stores/UserIdentityStore.js rename to src/matrix/storage/idb/stores/UserIdentityStore.ts index 1cf6d636..b84a2709 100644 --- a/src/matrix/storage/idb/stores/UserIdentityStore.js +++ b/src/matrix/storage/idb/stores/UserIdentityStore.ts @@ -13,21 +13,30 @@ 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 UserIdentity { + userId: string; + roomIds: string[]; + deviceTrackingStatus: number; +} export class UserIdentityStore { - constructor(store) { + private _store: Store; + + constructor(store: Store) { this._store = store; } - get(userId) { + get(userId: string): Promise { return this._store.get(userId); } - set(userIdentity) { - this._store.put(userIdentity); + set(userIdentity: UserIdentity): Promise { + return this._store.put(userIdentity); } - remove(userId) { + remove(userId: string): Promise { return this._store.delete(userId); } }