mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-19 23:03:51 +02:00
use async/await on update()
This commit is contained in:
@@ -3287,9 +3287,8 @@ CefSharp.BindObjectAsync(
|
||||
LogWatcher.Reset().then(() => {
|
||||
API.$on('SHOW_WORLD_DIALOG', (tag) => this.showWorldDialog(tag));
|
||||
API.$on('SHOW_LAUNCH_DIALOG', (tag) => this.showLaunchDialog(tag));
|
||||
setInterval(() => this.update(), 1000);
|
||||
setInterval(() => this.refreshGameLog(), 100);
|
||||
this.update();
|
||||
this.updateLoop();
|
||||
this.updateGameLogLoop();
|
||||
this.$nextTick(function () {
|
||||
this.$el.style.display = '';
|
||||
this.loginForm.loading = true;
|
||||
@@ -3354,10 +3353,9 @@ CefSharp.BindObjectAsync(
|
||||
});
|
||||
};
|
||||
|
||||
$app.methods.update = function () {
|
||||
if (API.isLoggedIn === false) {
|
||||
return;
|
||||
}
|
||||
$app.methods.updateLoop = function () {
|
||||
try {
|
||||
if (API.isLoggedIn === true) {
|
||||
if (--this.nextRefresh <= 0) {
|
||||
this.nextRefresh = 60;
|
||||
API.getCurrentUser().catch((err1) => {
|
||||
@@ -3388,6 +3386,11 @@ CefSharp.BindObjectAsync(
|
||||
this.updateDiscord();
|
||||
this.updateOpenVR();
|
||||
});
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
setTimeout(() => this.updateLoop(), 500);
|
||||
};
|
||||
|
||||
$app.methods.updateSharedFeed = function () {
|
||||
@@ -4470,11 +4473,25 @@ CefSharp.BindObjectAsync(
|
||||
});
|
||||
};
|
||||
|
||||
$app.methods.refreshGameLog = async function () {
|
||||
if (API.isLoggedIn !== true) {
|
||||
return;
|
||||
$app.methods.updateGameLogLoop = async function () {
|
||||
try {
|
||||
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;
|
||||
|
||||
for (var [fileName, dt, type, ...args] of await LogWatcher.Get()) {
|
||||
@@ -4556,16 +4573,8 @@ CefSharp.BindObjectAsync(
|
||||
this.gameLogTable.data.push(gameLogTableData);
|
||||
}
|
||||
}
|
||||
|
||||
this.sweepGameLog();
|
||||
|
||||
if (this.gameLogTable.data.length > 0) {
|
||||
this.notifyMenu('gameLog');
|
||||
}
|
||||
|
||||
this.updateSharedFeed();
|
||||
};
|
||||
|
||||
$app.methods.sweepGameLog = function () {
|
||||
var { data } = this.gameLogTable;
|
||||
// 로그는 7일까지만 남김
|
||||
|
||||
@@ -647,8 +647,8 @@ CefSharp.BindObjectAsync(
|
||||
// FIXME: 어케 복구하냐 이건
|
||||
throw err;
|
||||
}).then((args) => {
|
||||
setInterval(() => this.update(), 1000);
|
||||
this.update();
|
||||
this.updateLoop();
|
||||
this.updateCpuUsageLoop();
|
||||
this.$nextTick(function () {
|
||||
if (this.appType === '1') {
|
||||
this.$el.style.display = '';
|
||||
@@ -659,12 +659,10 @@ CefSharp.BindObjectAsync(
|
||||
}
|
||||
};
|
||||
|
||||
$app.methods.update = function () {
|
||||
$app.methods.updateLoop = async function () {
|
||||
try {
|
||||
this.currentTime = new Date().toJSON();
|
||||
this.currentUser = VRCXStorage.GetObject('currentUser') || {};
|
||||
VRCX.CpuUsage().then((cpuUsage) => {
|
||||
this.cpuUsage = cpuUsage.toFixed(2);
|
||||
});
|
||||
if (VRCXStorage.GetBool('VRCX_hideDevicesFromFeed') === false) {
|
||||
VRCX.GetVRDevices().then((devices) => {
|
||||
devices.forEach((device) => {
|
||||
@@ -677,6 +675,20 @@ CefSharp.BindObjectAsync(
|
||||
this.devices = '';
|
||||
}
|
||||
this.updateSharedFeed();
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
setTimeout(() => this.updateLoop(), 500);
|
||||
};
|
||||
|
||||
$app.methods.updateCpuUsageLoop = async function() {
|
||||
try {
|
||||
var cpuUsage = await VRCX.CpuUsage();
|
||||
this.cpuUsage = cpuUsage.toFixed(2);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
setTimeout(() => this.updateCpuUsageLoop(), 1000);
|
||||
};
|
||||
|
||||
$app.methods.updateSharedFeed = function () {
|
||||
|
||||
Reference in New Issue
Block a user