mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-05-06 14:46:04 +02:00
Further reduce calls of API.getCurrentUser (#899)
* Move nextCurrentUserRefresh set into API.getCurrentUser * Fix loop reset * Don't get user on refreshFriends too fast
This commit is contained in:
+5
-3
@@ -1905,6 +1905,7 @@ speechSynthesis.getVoices();
|
|||||||
};
|
};
|
||||||
|
|
||||||
API.getCurrentUser = function () {
|
API.getCurrentUser = function () {
|
||||||
|
$app.nextCurrentUserRefresh = 840; // 7mins
|
||||||
return this.call('auth/user', {
|
return this.call('auth/user', {
|
||||||
method: 'GET'
|
method: 'GET'
|
||||||
}).then((json) => {
|
}).then((json) => {
|
||||||
@@ -5773,7 +5774,6 @@ speechSynthesis.getVoices();
|
|||||||
if (API.isLoggedIn === true) {
|
if (API.isLoggedIn === true) {
|
||||||
if (--this.nextFriendsRefresh <= 0) {
|
if (--this.nextFriendsRefresh <= 0) {
|
||||||
this.nextFriendsRefresh = 7200; // 1hour
|
this.nextFriendsRefresh = 7200; // 1hour
|
||||||
this.nextCurrentUserRefresh = 840; // 7mins
|
|
||||||
this.refreshFriendsList();
|
this.refreshFriendsList();
|
||||||
this.updateStoredUser(API.currentUser);
|
this.updateStoredUser(API.currentUser);
|
||||||
if (this.isGameRunning) {
|
if (this.isGameRunning) {
|
||||||
@@ -5781,7 +5781,6 @@ speechSynthesis.getVoices();
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (--this.nextCurrentUserRefresh <= 0) {
|
if (--this.nextCurrentUserRefresh <= 0) {
|
||||||
this.nextCurrentUserRefresh = 840; // 7mins
|
|
||||||
API.getCurrentUser();
|
API.getCurrentUser();
|
||||||
}
|
}
|
||||||
if (--this.nextGroupInstanceRefresh <= 0) {
|
if (--this.nextGroupInstanceRefresh <= 0) {
|
||||||
@@ -9118,10 +9117,13 @@ speechSynthesis.getVoices();
|
|||||||
});
|
});
|
||||||
|
|
||||||
$app.methods.refreshFriendsList = async function () {
|
$app.methods.refreshFriendsList = async function () {
|
||||||
|
// If we just got user less then 1 min before code call, don't call it again
|
||||||
|
if ($app.nextCurrentUserRefresh < 720)
|
||||||
|
{
|
||||||
await API.getCurrentUser().catch((err) => {
|
await API.getCurrentUser().catch((err) => {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
});
|
});
|
||||||
this.nextCurrentUserRefresh = 840; // 7mins
|
}
|
||||||
await API.refreshFriends();
|
await API.refreshFriends();
|
||||||
API.reconnectWebSocket();
|
API.reconnectWebSocket();
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user