From f58af883b8287cbca5d3c70444ee588e38e98623 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Mon, 4 Feb 2019 22:29:46 +0000 Subject: [PATCH] remove (circular) dependency on sync in session --- src/session.js | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/src/session.js b/src/session.js index 9ae9b98c..ccd0b998 100644 --- a/src/session.js +++ b/src/session.js @@ -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); } } \ No newline at end of file