mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 03:25:12 +01:00
make starting a transaction async so we can do more synchronization later on
This commit is contained in:
parent
48a47cb639
commit
c70376e82d
@ -11,14 +11,14 @@ export default class Session {
|
|||||||
// loginData has device_id, user_id, home_server, access_token
|
// loginData has device_id, user_id, home_server, access_token
|
||||||
async setLoginData(loginData) {
|
async setLoginData(loginData) {
|
||||||
console.log("session.setLoginData");
|
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};
|
const session = {loginData};
|
||||||
txn.session.set(session);
|
txn.session.set(session);
|
||||||
await txn.complete();
|
await txn.complete();
|
||||||
}
|
}
|
||||||
|
|
||||||
async load() {
|
async load() {
|
||||||
const txn = this._storage.readTxn([
|
const txn = await this._storage.readTxn([
|
||||||
this._storage.storeNames.session,
|
this._storage.storeNames.session,
|
||||||
this._storage.storeNames.roomSummary,
|
this._storage.storeNames.roomSummary,
|
||||||
this._storage.storeNames.roomState,
|
this._storage.storeNames.roomState,
|
||||||
|
@ -19,13 +19,13 @@ export default class Storage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
readTxn(storeNames) {
|
async readTxn(storeNames) {
|
||||||
this._validateStoreNames(storeNames);
|
this._validateStoreNames(storeNames);
|
||||||
const txn = this._db.transaction(storeNames, "readonly");
|
const txn = this._db.transaction(storeNames, "readonly");
|
||||||
return new Transaction(txn, storeNames);
|
return new Transaction(txn, storeNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
readWriteTxn(storeNames) {
|
async readWriteTxn(storeNames) {
|
||||||
this._validateStoreNames(storeNames);
|
this._validateStoreNames(storeNames);
|
||||||
const txn = this._db.transaction(storeNames, "readwrite");
|
const txn = this._db.transaction(storeNames, "readwrite");
|
||||||
return new Transaction(txn, storeNames);
|
return new Transaction(txn, storeNames);
|
||||||
|
@ -70,7 +70,7 @@ export default class Sync extends EventEmitter {
|
|||||||
const response = await this._currentRequest.response();
|
const response = await this._currentRequest.response();
|
||||||
syncToken = response.next_batch;
|
syncToken = response.next_batch;
|
||||||
const storeNames = this._storage.storeNames;
|
const storeNames = this._storage.storeNames;
|
||||||
const syncTxn = this._storage.readWriteTxn([
|
const syncTxn = await this._storage.readWriteTxn([
|
||||||
storeNames.session,
|
storeNames.session,
|
||||||
storeNames.roomSummary,
|
storeNames.roomSummary,
|
||||||
storeNames.roomTimeline,
|
storeNames.roomTimeline,
|
||||||
|
Loading…
Reference in New Issue
Block a user