mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 03:25:12 +01:00
remove (circular) dependency on sync in session
This commit is contained in:
parent
f0e5757692
commit
f58af883b8
@ -1,34 +1,28 @@
|
|||||||
class Session {
|
export default class Session {
|
||||||
// sessionData has device_id and access_token
|
// sessionData has device_id, user_id, home_server (not access_token, that is for network)
|
||||||
constructor(sessionData) {
|
constructor(sessionData, storage) {
|
||||||
this._sessionData = sessionData;
|
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?
|
// 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) {
|
getRoom(roomId) {
|
||||||
return this._rooms[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);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user