Merge pull request #1662 from ZyGout/fix-SessionManager
fix(SessionManager): SessionManager.fetch() returning an empty SessionManager
This commit is contained in:
@@ -19,21 +19,20 @@ class SessionManager extends CachedManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch all sessions of the client.
|
* Fetch all sessions of the client.
|
||||||
* @returns {Promise<SessionManager>}
|
* @returns {Promise<Collection<string, Session>>}
|
||||||
*/
|
*/
|
||||||
fetch() {
|
fetch() {
|
||||||
return new Promise((resolve, reject) => {
|
return this.client.api.auth.sessions
|
||||||
this.client.api.auth.sessions
|
|
||||||
.get()
|
.get()
|
||||||
.then(data => {
|
.then(data => {
|
||||||
const allData = data.user_sessions;
|
const allData = data.user_sessions;
|
||||||
|
|
||||||
this.cache.clear();
|
this.cache.clear();
|
||||||
for (const session of allData) {
|
for (const session of allData) {
|
||||||
this._add(new Session(this.client, session), true, { id: session.id_hash });
|
this._add(session, true, { id: session.id_hash });
|
||||||
}
|
}
|
||||||
resolve(this);
|
|
||||||
})
|
return this.cache;
|
||||||
.catch(reject);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user