From eb0ddf864d79afe90b0ecece4886286904e63ebc Mon Sep 17 00:00:00 2001 From: Natsumi Date: Thu, 31 Dec 2020 17:33:30 +1300 Subject: [PATCH] Self online/offline time --- html/src/app.js | 17 ++++++++++++++++- html/src/index.pug | 2 +- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/html/src/app.js b/html/src/app.js index 165d4c9f..e51d662b 100644 --- a/html/src/app.js +++ b/html/src/app.js @@ -1146,6 +1146,8 @@ speechSynthesis.getVoices(); json.state = API.currentUser.state; json.last_login = API.currentUser.last_login; json.location = ($app.isGameRunning === true) ? $app.lastLocation : ''; + json.$online_for = API.currentUser.$online_for; + json.$offline_for = API.currentUser.$offline_for; } if (ref === undefined) { ref = { @@ -5774,6 +5776,19 @@ speechSynthesis.getVoices(); configRepository.setString('VRCX_notificationPosition', this.notificationPosition); }; + var isGameRunningStateChange = function () { + $app.lastLocation = ''; + if (this.isGameRunning) { + API.currentUser.$online_for = Date.now(); + API.currentUser.$offline_for = ''; + } + else { + API.currentUser.$online_for = ''; + API.currentUser.$offline_for = Date.now(); + } + } + $app.watch.isGameRunning = isGameRunningStateChange; + API.$on('LOGIN', function () { $app.currentUserTreeData = []; $app.pastDisplayNameTable.data = []; @@ -7760,7 +7775,7 @@ speechSynthesis.getVoices(); return arr.join(' '); }; - if (ctx.ref.state === 'online') { + if ((ctx.ref.state === 'online') && (ctx.ref.$online_for)) { return timeToText(Date.now() - ctx.ref.$online_for) } else if (ctx.ref.$offline_for) { return timeToText(Date.now() - ctx.ref.$offline_for) diff --git a/html/src/index.pug b/html/src/index.pug index f1a1df07..e17360f7 100644 --- a/html/src/index.pug +++ b/html/src/index.pug @@ -825,7 +825,7 @@ html span.extra(v-else style="color:#F56C6C") Deny .x-friend-item .detail - span.name(v-if="userDialog.ref.state === 'online'") Online For + span.name(v-if="userDialog.ref.state === 'online' && userDialog.ref.$online_for") Online For span.name(v-else) Offline For span.extra(v-text="userOnlineFor(userDialog)") .x-friend-item