Skip to content
This repository has been archived by the owner on Dec 9, 2023. It is now read-only.

Commit

Permalink
clearCurrentUserCacheIfNeeded
Browse files Browse the repository at this point in the history
  • Loading branch information
LukePulverenti committed Sep 11, 2018
1 parent c8e4829 commit ca2eb8b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions apiclient.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,15 @@ function getFetchPromise(request) {
return fetchWithTimeout(request.url, fetchRequest, request.timeout);
}

function clearCurrentUserCacheIfNeeded(apiClient) {

var user = apiClient._currentUser;
var serverInfo = apiClient._serverInfo;
if (user && serverInfo && user.Id !== serverInfo.UserId) {
apiClient._currentUser = null;
}
}

/**
* Creates a new api client instance
* @param {String} serverAddress
Expand Down Expand Up @@ -385,6 +394,7 @@ class ApiClient {

this._serverInfo.AccessToken = accessKey;
this._serverInfo.UserId = userId;
clearCurrentUserCacheIfNeeded(this);
redetectBitrate(this);
refreshWakeOnLanInfoIfNeeded(this);
}
Expand All @@ -393,6 +403,7 @@ class ApiClient {

if (info) {
this._serverInfo = info;
clearCurrentUserCacheIfNeeded(this);
}

return this._serverInfo;
Expand Down
2 changes: 1 addition & 1 deletion connectionmanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ export default class ConnectionManager {
let connectUser;
self.connectUser = () => connectUser;

self._minServerVersion = '3.2.33';
self._minServerVersion = '3.3.0';

self.appVersion = () => appVersion;

Expand Down

0 comments on commit ca2eb8b

Please sign in to comment.