Adjust refresh interval

This commit is contained in:
Natsumi
2021-03-28 01:49:50 +13:00
parent 25671e397a
commit 0a3e626e18

View File

@@ -378,7 +378,7 @@ speechSynthesis.getVoices();
try { try {
response.data = JSON.parse(response.data); response.data = JSON.parse(response.data);
if ($app.debug) { if ($app.debug) {
console.log(init, response); console.log(init, response.data);
} }
return response; return response;
} catch (e) { } catch (e) {
@@ -3547,7 +3547,8 @@ speechSynthesis.getVoices();
var $app = { var $app = {
data: { data: {
API, API,
nextRefresh: 0, nextCurrentUserRefresh: 0,
nextFriendsRefresh: 0,
isGameRunning: false, isGameRunning: false,
isGameNoVR: false, isGameNoVR: false,
appVersion: 'VRCX 2021.03.08', appVersion: 'VRCX 2021.03.08',
@@ -3636,13 +3637,16 @@ speechSynthesis.getVoices();
$app.methods.updateLoop = function () { $app.methods.updateLoop = function () {
try { try {
if (API.isLoggedIn === true) { if (API.isLoggedIn === true) {
if (--this.nextRefresh <= 0) { if (--this.nextCurrentUserRefresh <= 0) {
this.nextRefresh = 60; this.nextCurrentUserRefresh = 120; // 1min
API.getCurrentUser().catch((err1) => { API.getCurrentUser().catch((err1) => {
throw err1; throw err1;
}); });
} }
this.checkActiveFriends(); if (--this.nextFriendsRefresh <= 0) {
this.nextFriendsRefresh = 7200; // 1hour
API.refreshFriends();
}
AppApi.CheckGameRunning().then(([isGameRunning, isGameNoVR]) => { AppApi.CheckGameRunning().then(([isGameRunning, isGameNoVR]) => {
if (isGameRunning !== this.isGameRunning) { if (isGameRunning !== this.isGameRunning) {
this.isGameRunning = isGameRunning; this.isGameRunning = isGameRunning;
@@ -4840,10 +4844,6 @@ speechSynthesis.getVoices();
this.deleteFriend(id); this.deleteFriend(id);
} }
} }
// called from API.login(), API.loginWithSteam(), API.getCurrentUser()
if (origin) {
API.refreshFriends();
}
}; };
$app.methods.addFriend = function (id, state) { $app.methods.addFriend = function (id, state) {