remove (circular) dependency on sync in session

This commit is contained in:
Bruno Windels 2019-02-04 22:29:46 +00:00
parent f0e5757692
commit f58af883b8
1 changed files with 15 additions and 21 deletions

View File

@ -1,34 +1,28 @@
class Session {
// sessionData has device_id and access_token
constructor(sessionData) {
export default class Session {
// sessionData has device_id, user_id, home_server (not access_token, that is for network)
constructor(sessionData, storage) {
this._sessionData = sessionData;
this._storage = storage;
this._rooms = {};
this._syncToken = null;
}
loadFromStorage() {
load() {
// what is the PK for a session [user_id, device_id], a uuid?
}
start() {
if (!this._syncToken) {
do initial sync
}
do incremental sync
}
stop() {
if (this._initialSync) {
this._initialSync.abort();
}
if (this._incrementalSync) {
this._incrementalSync.stop();
}
}
getRoom(roomId) {
return this._rooms[roomId];
}
applySync(newRooms, syncToken, accountData) {
createRoom(roomId) {
const room = new Room(roomId, this._storage);
this._rooms[roomId] = room;
return room;
}
applySync(syncToken, accountData, txn) {
this._syncToken = syncToken;
txn.session.setSyncToken(syncToken);
}
}