make starting a transaction async so we can do more synchronization later on

This commit is contained in:
Bruno Windels 2019-02-16 00:27:13 +01:00
parent 48a47cb639
commit c70376e82d
3 changed files with 5 additions and 5 deletions

View File

@ -11,14 +11,14 @@ export default class Session {
// loginData has device_id, user_id, home_server, access_token
async setLoginData(loginData) {
console.log("session.setLoginData");
const txn = this._storage.readWriteTxn([this._storage.storeNames.session]);
const txn = await this._storage.readWriteTxn([this._storage.storeNames.session]);
const session = {loginData};
txn.session.set(session);
await txn.complete();
}
async load() {
const txn = this._storage.readTxn([
const txn = await this._storage.readTxn([
this._storage.storeNames.session,
this._storage.storeNames.roomSummary,
this._storage.storeNames.roomState,

View File

@ -19,13 +19,13 @@ export default class Storage {
}
}
readTxn(storeNames) {
async readTxn(storeNames) {
this._validateStoreNames(storeNames);
const txn = this._db.transaction(storeNames, "readonly");
return new Transaction(txn, storeNames);
}
readWriteTxn(storeNames) {
async readWriteTxn(storeNames) {
this._validateStoreNames(storeNames);
const txn = this._db.transaction(storeNames, "readwrite");
return new Transaction(txn, storeNames);

View File

@ -70,7 +70,7 @@ export default class Sync extends EventEmitter {
const response = await this._currentRequest.response();
syncToken = response.next_batch;
const storeNames = this._storage.storeNames;
const syncTxn = this._storage.readWriteTxn([
const syncTxn = await this._storage.readWriteTxn([
storeNames.session,
storeNames.roomSummary,
storeNames.roomTimeline,