This repository has been archived on 2022-08-19. You can view files and clone it, but cannot push or open issues or pull requests.
hydrogen-web/src/storage/idb/stores/SessionStore.js

33 lines
501 B
JavaScript
Raw Normal View History

2019-02-07 04:49:29 +05:30
/**
store contains:
loginData {
device_id
home_server
access_token
user_id
}
// flags {
// lazyLoading?
// }
syncToken
displayName
avatarUrl
lastSynced
*/
2019-02-07 05:50:27 +05:30
export default class SessionStore {
2019-02-07 04:49:29 +05:30
constructor(sessionStore) {
this._sessionStore = sessionStore;
}
2019-02-07 05:50:27 +05:30
async get() {
const session = await this._sessionStore.selectFirst(IDBKeyRange.only(1));
if (session) {
return session.value;
}
}
2019-02-07 05:50:27 +05:30
set(session) {
return this._sessionStore.put({key: 1, value: session});
}
}