mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-19 14:53:50 +02:00
use async/await on update()
This commit is contained in:
103
html/src/app.js
103
html/src/app.js
@@ -3287,9 +3287,8 @@ CefSharp.BindObjectAsync(
|
|||||||
LogWatcher.Reset().then(() => {
|
LogWatcher.Reset().then(() => {
|
||||||
API.$on('SHOW_WORLD_DIALOG', (tag) => this.showWorldDialog(tag));
|
API.$on('SHOW_WORLD_DIALOG', (tag) => this.showWorldDialog(tag));
|
||||||
API.$on('SHOW_LAUNCH_DIALOG', (tag) => this.showLaunchDialog(tag));
|
API.$on('SHOW_LAUNCH_DIALOG', (tag) => this.showLaunchDialog(tag));
|
||||||
setInterval(() => this.update(), 1000);
|
this.updateLoop();
|
||||||
setInterval(() => this.refreshGameLog(), 100);
|
this.updateGameLogLoop();
|
||||||
this.update();
|
|
||||||
this.$nextTick(function () {
|
this.$nextTick(function () {
|
||||||
this.$el.style.display = '';
|
this.$el.style.display = '';
|
||||||
this.loginForm.loading = true;
|
this.loginForm.loading = true;
|
||||||
@@ -3354,40 +3353,44 @@ CefSharp.BindObjectAsync(
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
$app.methods.update = function () {
|
$app.methods.updateLoop = function () {
|
||||||
if (API.isLoggedIn === false) {
|
try {
|
||||||
return;
|
if (API.isLoggedIn === true) {
|
||||||
}
|
if (--this.nextRefresh <= 0) {
|
||||||
if (--this.nextRefresh <= 0) {
|
this.nextRefresh = 60;
|
||||||
this.nextRefresh = 60;
|
API.getCurrentUser().catch((err1) => {
|
||||||
API.getCurrentUser().catch((err1) => {
|
if (err1.status_code === 401) {
|
||||||
if (err1.status_code === 401) {
|
API.getConfig().then((args) => {
|
||||||
API.getConfig().then((args) => {
|
API.login({
|
||||||
API.login({
|
username: this.loginForm.username,
|
||||||
username: this.loginForm.username,
|
password: this.loginForm.password
|
||||||
password: this.loginForm.password
|
}).catch((err2) => {
|
||||||
}).catch((err2) => {
|
if (err2.status_code === 401) {
|
||||||
if (err2.status_code === 401) {
|
API.logout();
|
||||||
API.logout();
|
}
|
||||||
}
|
throw err2;
|
||||||
throw err2;
|
});
|
||||||
});
|
return args;
|
||||||
return args;
|
});
|
||||||
|
}
|
||||||
|
throw err1;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
throw err1;
|
this.checkActiveFriends();
|
||||||
});
|
VRCX.CheckGameRunning().then(([isGameRunning, isGameNoVR]) => {
|
||||||
}
|
if (isGameRunning !== this.isGameRunning) {
|
||||||
this.checkActiveFriends();
|
this.isGameRunning = isGameRunning;
|
||||||
VRCX.CheckGameRunning().then(([isGameRunning, isGameNoVR]) => {
|
Discord.SetTimestamps(Date.now(), 0);
|
||||||
if (isGameRunning !== this.isGameRunning) {
|
}
|
||||||
this.isGameRunning = isGameRunning;
|
this.isGameNoVR = isGameNoVR;
|
||||||
Discord.SetTimestamps(Date.now(), 0);
|
this.updateDiscord();
|
||||||
|
this.updateOpenVR();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
this.isGameNoVR = isGameNoVR;
|
} catch (err) {
|
||||||
this.updateDiscord();
|
console.error(err);
|
||||||
this.updateOpenVR();
|
}
|
||||||
});
|
setTimeout(() => this.updateLoop(), 500);
|
||||||
};
|
};
|
||||||
|
|
||||||
$app.methods.updateSharedFeed = function () {
|
$app.methods.updateSharedFeed = function () {
|
||||||
@@ -4470,11 +4473,25 @@ CefSharp.BindObjectAsync(
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
$app.methods.refreshGameLog = async function () {
|
$app.methods.updateGameLogLoop = async function () {
|
||||||
if (API.isLoggedIn !== true) {
|
try {
|
||||||
return;
|
if (API.isLoggedIn === true) {
|
||||||
}
|
await this.updateGameLog();
|
||||||
|
this.sweepGameLog();
|
||||||
|
|
||||||
|
if (this.gameLogTable.data.length > 0) {
|
||||||
|
this.notifyMenu('gameLog');
|
||||||
|
}
|
||||||
|
|
||||||
|
this.updateSharedFeed();
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
}
|
||||||
|
setTimeout(() => this.updateGameLogLoop(), 1000);
|
||||||
|
};
|
||||||
|
|
||||||
|
$app.methods.updateGameLog = async function () {
|
||||||
var currentUser = API.currentUser.username;
|
var currentUser = API.currentUser.username;
|
||||||
|
|
||||||
for (var [fileName, dt, type, ...args] of await LogWatcher.Get()) {
|
for (var [fileName, dt, type, ...args] of await LogWatcher.Get()) {
|
||||||
@@ -4556,15 +4573,7 @@ CefSharp.BindObjectAsync(
|
|||||||
this.gameLogTable.data.push(gameLogTableData);
|
this.gameLogTable.data.push(gameLogTableData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
this.sweepGameLog();
|
|
||||||
|
|
||||||
if (this.gameLogTable.data.length > 0) {
|
|
||||||
this.notifyMenu('gameLog');
|
|
||||||
}
|
|
||||||
|
|
||||||
this.updateSharedFeed();
|
|
||||||
};
|
|
||||||
|
|
||||||
$app.methods.sweepGameLog = function () {
|
$app.methods.sweepGameLog = function () {
|
||||||
var { data } = this.gameLogTable;
|
var { data } = this.gameLogTable;
|
||||||
|
|||||||
@@ -647,8 +647,8 @@ CefSharp.BindObjectAsync(
|
|||||||
// FIXME: 어케 복구하냐 이건
|
// FIXME: 어케 복구하냐 이건
|
||||||
throw err;
|
throw err;
|
||||||
}).then((args) => {
|
}).then((args) => {
|
||||||
setInterval(() => this.update(), 1000);
|
this.updateLoop();
|
||||||
this.update();
|
this.updateCpuUsageLoop();
|
||||||
this.$nextTick(function () {
|
this.$nextTick(function () {
|
||||||
if (this.appType === '1') {
|
if (this.appType === '1') {
|
||||||
this.$el.style.display = '';
|
this.$el.style.display = '';
|
||||||
@@ -659,24 +659,36 @@ CefSharp.BindObjectAsync(
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$app.methods.update = function () {
|
$app.methods.updateLoop = async function () {
|
||||||
this.currentTime = new Date().toJSON();
|
try {
|
||||||
this.currentUser = VRCXStorage.GetObject('currentUser') || {};
|
this.currentTime = new Date().toJSON();
|
||||||
VRCX.CpuUsage().then((cpuUsage) => {
|
this.currentUser = VRCXStorage.GetObject('currentUser') || {};
|
||||||
this.cpuUsage = cpuUsage.toFixed(2);
|
if (VRCXStorage.GetBool('VRCX_hideDevicesFromFeed') === false) {
|
||||||
});
|
VRCX.GetVRDevices().then((devices) => {
|
||||||
if (VRCXStorage.GetBool('VRCX_hideDevicesFromFeed') === false) {
|
devices.forEach((device) => {
|
||||||
VRCX.GetVRDevices().then((devices) => {
|
device[2] = parseInt(device[2], 10);
|
||||||
devices.forEach((device) => {
|
});
|
||||||
device[2] = parseInt(device[2], 10);
|
this.devices = devices;
|
||||||
});
|
});
|
||||||
this.devices = devices;
|
}
|
||||||
});
|
else {
|
||||||
|
this.devices = '';
|
||||||
|
}
|
||||||
|
this.updateSharedFeed();
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
}
|
}
|
||||||
else {
|
setTimeout(() => this.updateLoop(), 500);
|
||||||
this.devices = '';
|
};
|
||||||
|
|
||||||
|
$app.methods.updateCpuUsageLoop = async function() {
|
||||||
|
try {
|
||||||
|
var cpuUsage = await VRCX.CpuUsage();
|
||||||
|
this.cpuUsage = cpuUsage.toFixed(2);
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
}
|
}
|
||||||
this.updateSharedFeed();
|
setTimeout(() => this.updateCpuUsageLoop(), 1000);
|
||||||
};
|
};
|
||||||
|
|
||||||
$app.methods.updateSharedFeed = function () {
|
$app.methods.updateSharedFeed = function () {
|
||||||
|
|||||||
Reference in New Issue
Block a user