mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 03:25:12 +01:00
Reduce IDBValidKey returns to the public API
This commit is contained in:
parent
ce20d40ff7
commit
16d3ed579b
@ -148,7 +148,7 @@ export class Store<T> extends QueryTarget<T> {
|
|||||||
return new QueryTarget<T>(new QueryTargetWrapper<T>(this._idbStore.index(indexName)));
|
return new QueryTarget<T>(new QueryTargetWrapper<T>(this._idbStore.index(indexName)));
|
||||||
}
|
}
|
||||||
|
|
||||||
put(value: T): Promise<IDBValidKey> {
|
put(value: T): void {
|
||||||
// If this request fails, the error will bubble up to the transaction and abort it,
|
// If this request fails, the error will bubble up to the transaction and abort it,
|
||||||
// which is the behaviour we want. Therefore, it is ok to not create a promise for this
|
// which is the behaviour we want. Therefore, it is ok to not create a promise for this
|
||||||
// request and await it.
|
// request and await it.
|
||||||
@ -159,12 +159,12 @@ export class Store<T> extends QueryTarget<T> {
|
|||||||
//
|
//
|
||||||
// Note that this can still throw synchronously, like it does for TransactionInactiveError,
|
// Note that this can still throw synchronously, like it does for TransactionInactiveError,
|
||||||
// see https://www.w3.org/TR/IndexedDB-2/#transaction-lifetime-concept
|
// see https://www.w3.org/TR/IndexedDB-2/#transaction-lifetime-concept
|
||||||
return reqAsPromise(this._idbStore.put(value));
|
this._idbStore.put(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
add(value: T): Promise<IDBValidKey> {
|
add(value: T): void {
|
||||||
// ok to not monitor result of request, see comment in `put`.
|
// ok to not monitor result of request, see comment in `put`.
|
||||||
return reqAsPromise(this._idbStore.add(value));
|
this._idbStore.add(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
delete(keyOrKeyRange: IDBValidKey | IDBKeyRange): Promise<undefined> {
|
delete(keyOrKeyRange: IDBValidKey | IDBKeyRange): Promise<undefined> {
|
||||||
|
@ -4,7 +4,7 @@ import {addRoomToIdentity} from "../../e2ee/DeviceTracker.js";
|
|||||||
import {RoomMemberStore} from "./stores/RoomMemberStore";
|
import {RoomMemberStore} from "./stores/RoomMemberStore";
|
||||||
import {SessionStore} from "./stores/SessionStore";
|
import {SessionStore} from "./stores/SessionStore";
|
||||||
import {encodeScopeTypeKey} from "./stores/OperationStore.js";
|
import {encodeScopeTypeKey} from "./stores/OperationStore.js";
|
||||||
import {MAX_UNICODE} from "./stores/common.js";
|
import {MAX_UNICODE} from "./stores/common";
|
||||||
|
|
||||||
// FUNCTIONS SHOULD ONLY BE APPENDED!!
|
// FUNCTIONS SHOULD ONLY BE APPENDED!!
|
||||||
// the index in the array is the database version
|
// the index in the array is the database version
|
||||||
|
@ -41,8 +41,8 @@ export class InviteStore {
|
|||||||
return this._inviteStore.selectAll();
|
return this._inviteStore.selectAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
set(invite: InviteData): Promise<IDBValidKey> {
|
set(invite: InviteData): void {
|
||||||
return this._inviteStore.put(invite);
|
this._inviteStore.put(invite);
|
||||||
}
|
}
|
||||||
|
|
||||||
remove(roomId: string): void {
|
remove(roomId: string): void {
|
||||||
|
@ -50,10 +50,10 @@ export class RoomMemberStore {
|
|||||||
return this._roomMembersStore.get(encodeKey(roomId, userId));
|
return this._roomMembersStore.get(encodeKey(roomId, userId));
|
||||||
}
|
}
|
||||||
|
|
||||||
async set(member: MemberData): Promise<IDBValidKey> {
|
set(member: MemberData): void {
|
||||||
// Object.assign would be more typesafe, but small objects
|
// Object.assign would be more typesafe, but small objects
|
||||||
(member as any).key = encodeKey(member.roomId, member.userId);
|
(member as any).key = encodeKey(member.roomId, member.userId);
|
||||||
return this._roomMembersStore.put(member as MemberStorageEntry);
|
this._roomMembersStore.put(member as MemberStorageEntry);
|
||||||
}
|
}
|
||||||
|
|
||||||
getAll(roomId: string): Promise<MemberData[]> {
|
getAll(roomId: string): Promise<MemberData[]> {
|
||||||
|
@ -42,8 +42,8 @@ export class RoomSummaryStore {
|
|||||||
return this._summaryStore.selectAll();
|
return this._summaryStore.selectAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
set(summary: SummaryData): Promise<IDBValidKey> {
|
set(summary: SummaryData): void {
|
||||||
return this._summaryStore.put(summary);
|
this._summaryStore.put(summary);
|
||||||
}
|
}
|
||||||
|
|
||||||
get(roomId: string): Promise<SummaryData | null> {
|
get(roomId: string): Promise<SummaryData | null> {
|
||||||
|
@ -27,7 +27,7 @@ export class SessionStore {
|
|||||||
this._sessionStore = sessionStore;
|
this._sessionStore = sessionStore;
|
||||||
}
|
}
|
||||||
|
|
||||||
async get(key: IDBValidKey): Promise<any> {
|
async get(key: string): Promise<any> {
|
||||||
const entry = await this._sessionStore.get(key);
|
const entry = await this._sessionStore.get(key);
|
||||||
if (entry) {
|
if (entry) {
|
||||||
return entry.value;
|
return entry.value;
|
||||||
@ -42,7 +42,7 @@ export class SessionStore {
|
|||||||
this._sessionStore.add({key, value});
|
this._sessionStore.add({key, value});
|
||||||
}
|
}
|
||||||
|
|
||||||
remove(key: IDBValidKey): void {
|
remove(key: string): void {
|
||||||
this._sessionStore.delete(key);
|
this._sessionStore.delete(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,8 +39,8 @@ export class TimelineRelationStore {
|
|||||||
this._store = store;
|
this._store = store;
|
||||||
}
|
}
|
||||||
|
|
||||||
add(roomId: string, targetEventId: string, relType: string, sourceEventId: string): Promise<IDBValidKey> {
|
add(roomId: string, targetEventId: string, relType: string, sourceEventId: string): void {
|
||||||
return this._store.add({key: encodeKey(roomId, targetEventId, relType, sourceEventId)});
|
this._store.add({key: encodeKey(roomId, targetEventId, relType, sourceEventId)});
|
||||||
}
|
}
|
||||||
|
|
||||||
remove(roomId: string, targetEventId: string, relType: string, sourceEventId: string): Promise<undefined> {
|
remove(roomId: string, targetEventId: string, relType: string, sourceEventId: string): Promise<undefined> {
|
||||||
|
Loading…
Reference in New Issue
Block a user