Add initial translation of SessionStore.js

This commit is contained in:
Danila Fedorin 2021-08-10 16:10:55 -07:00
parent 97a50c835d
commit 5177c35d0d
3 changed files with 19 additions and 16 deletions

View File

@ -17,7 +17,7 @@ limitations under the License.
import {txnAsPromise} from "./utils"; import {txnAsPromise} from "./utils";
import {StorageError} from "../common"; import {StorageError} from "../common";
import {Store} from "./Store"; import {Store} from "./Store";
import {SessionStore} from "./stores/SessionStore.js"; import {SessionStore} from "./stores/SessionStore";
import {RoomSummaryStore} from "./stores/RoomSummaryStore.js"; import {RoomSummaryStore} from "./stores/RoomSummaryStore.js";
import {InviteStore} from "./stores/InviteStore.js"; import {InviteStore} from "./stores/InviteStore.js";
import {TimelineEventStore} from "./stores/TimelineEventStore.js"; import {TimelineEventStore} from "./stores/TimelineEventStore.js";

View File

@ -1,7 +1,7 @@
import {iterateCursor, reqAsPromise} from "./utils"; import {iterateCursor, reqAsPromise} from "./utils";
import {RoomMember, EVENT_TYPE as MEMBER_EVENT_TYPE} from "../../room/members/RoomMember.js"; import {RoomMember, EVENT_TYPE as MEMBER_EVENT_TYPE} from "../../room/members/RoomMember.js";
import {RoomMemberStore} from "./stores/RoomMemberStore.js"; import {RoomMemberStore} from "./stores/RoomMemberStore.js";
import {SessionStore} from "./stores/SessionStore.js"; import {SessionStore} from "./stores/SessionStore";
import {encodeScopeTypeKey} from "./stores/OperationStore.js"; import {encodeScopeTypeKey} from "./stores/OperationStore.js";
// FUNCTIONS SHOULD ONLY BE APPENDED!! // FUNCTIONS SHOULD ONLY BE APPENDED!!

View File

@ -13,28 +13,31 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import {Store} from "../Store"
export class SessionStore { export class SessionStore {
constructor(sessionStore) { private _sessionStore: Store<any>
constructor(sessionStore: Store<any>) {
this._sessionStore = sessionStore; this._sessionStore = sessionStore;
} }
async get(key) { async get(key: IDBValidKey) {
const entry = await this._sessionStore.get(key); const entry = await this._sessionStore.get(key);
if (entry) { if (entry) {
return entry.value; return entry.value;
} }
} }
set(key, value) { set(key: IDBValidKey, value: any) {
this._sessionStore.put({key, value}); this._sessionStore.put({key, value});
} }
add(key, value) { add(key: IDBValidKey, value: any) {
this._sessionStore.add({key, value}); this._sessionStore.add({key, value});
} }
remove(key) { remove(key: IDBValidKey) {
this._sessionStore.delete(key); this._sessionStore.delete(key);
} }
} }