From 704268bb1bfbbc1a70ef3d9df915137a1da1a1e9 Mon Sep 17 00:00:00 2001 From: Natsumi Date: Mon, 4 Dec 2023 20:51:46 +1300 Subject: [PATCH] Make use of queuedInstance to add/remove queued instances --- html/src/app.js | 71 +++++++++++++++++++++++++++----- html/src/localization/en/en.json | 2 +- html/src/theme.darkvanilla.scss | 6 +-- 3 files changed, 64 insertions(+), 15 deletions(-) diff --git a/html/src/app.js b/html/src/app.js index 45b549ab8..17d24db31 100644 --- a/html/src/app.js +++ b/html/src/app.js @@ -1637,6 +1637,7 @@ speechSynthesis.getVoices(); this.applyUserTrustLevel(ref); this.applyUserLanguage(ref); this.applyPresenceLocation(ref); + this.applyQueuedInstance(ref.queuedInstance); // update group list if (json.presence?.groups) { for (var groupId of json.presence.groups) { @@ -1663,6 +1664,7 @@ speechSynthesis.getVoices(); currentAvatar: '', currentAvatarAssetUrl: '', currentAvatarImageUrl: '', + currentAvatarTags: [], currentAvatarThumbnailImageUrl: '', date_joined: '', developerType: '', @@ -1672,10 +1674,12 @@ speechSynthesis.getVoices(); friendGroupNames: [], friendKey: '', friends: [], + googleId: '', hasBirthday: false, hasEmail: false, hasLoggedInFromClient: false, hasPendingEmail: false, + hideContentFilterSettings: false, homeLocation: '', id: '', isFriend: false, @@ -1688,8 +1692,10 @@ speechSynthesis.getVoices(); offlineFriends: [], onlineFriends: [], pastDisplayNames: [], + picoId: '', presence: { avatarThumbnail: '', + currentAvatarTags: '', displayName: '', groups: [], id: '', @@ -1700,10 +1706,12 @@ speechSynthesis.getVoices(); status: '', travelingToInstance: '', travelingToWorld: '', + userIcon: '', world: '', ...json.presence }, profilePicOverride: '', + queuedInstance: '', state: '', status: '', statusDescription: '', @@ -1717,7 +1725,10 @@ speechSynthesis.getVoices(); unsubscribe: false, updated_at: '', userIcon: '', + userLanguage: '', + userLanguageCode: '', username: '', + viveId: '', // VRCX $online_for: Date.now(), $offline_for: '', @@ -26834,6 +26845,10 @@ speechSynthesis.getVoices(); $app.methods.removeAllQueuedInstances = function () { API.queuedInstances.forEach((ref) => { + this.$message({ + message: `Removed instance ${ref.$worldName} from queue`, + type: 'info' + }); ref.$msgBox?.close(); }); API.queuedInstances.clear(); @@ -26847,6 +26862,40 @@ speechSynthesis.getVoices(); } }; + API.applyQueuedInstance = function (instanceId) { + API.queuedInstances.forEach((ref) => { + if (ref.location !== instanceId) { + $app.$message({ + message: `Removed instance ${ref.$worldName} from queue`, + type: 'info' + }); + ref.$msgBox?.close(); + API.queuedInstances.delete(ref.location); + } + }); + if (!instanceId) { + return; + } + if (!API.queuedInstances.has(instanceId)) { + var L = API.parseLocation(instanceId); + if (L.worldId && L.instanceId) { + API.getInstance({ + worldId: L.worldId, + instanceId: L.instanceId + }).then((args) => { + if (args.json?.queueSize) { + $app.instanceQueueUpdate( + instanceId, + args.json?.queueSize, + args.json?.queueSize + ); + } + }); + } + $app.instanceQueueUpdate(instanceId, 0, 0); + } + }; + $app.methods.instanceQueueReady = function (instanceId) { var ref = API.queuedInstances.get(instanceId); if (typeof ref !== 'undefined') { @@ -26922,19 +26971,19 @@ speechSynthesis.getVoices(); ); ref.$msgBox.message = `You are in position ${ref.position} of ${ref.queueSize} in the queue for ${displayLocation} `; API.queuedInstances.set(instanceId, ref); - workerTimers.setTimeout(this.instanceQueueTimeout, 3600000); + // workerTimers.setTimeout(this.instanceQueueTimeout, 3600000); }; - $app.methods.instanceQueueTimeout = function () { - // remove instance from queue after 1hour of inactivity - API.queuedInstances.forEach((ref) => { - // 59mins - if (Date.now() - ref.updatedAt > 3540000) { - ref.$msgBox.close(); - API.queuedInstances.delete(ref.location); - } - }); - }; + // $app.methods.instanceQueueTimeout = function () { + // // remove instance from queue after 1hour of inactivity + // API.queuedInstances.forEach((ref) => { + // // 59mins + // if (Date.now() - ref.updatedAt > 3540000) { + // ref.$msgBox.close(); + // API.queuedInstances.delete(ref.location); + // } + // }); + // }; /** * @param {{ groupId: string }} params diff --git a/html/src/localization/en/en.json b/html/src/localization/en/en.json index 25961a6b1..d1cf403a1 100644 --- a/html/src/localization/en/en.json +++ b/html/src/localization/en/en.json @@ -323,7 +323,7 @@ "when_to_display_game_closed": "Game Closed", "when_to_display_game_running": "Game Running", "when_to_display_always": "Always", - "desktop_notification_while_afk": "Desktop Notification While AFK" + "desktop_notification_while_afk": "Desktop Notifications While AFK" }, "text_to_speech": { "header": "Text-To-Speech Options", diff --git a/html/src/theme.darkvanilla.scss b/html/src/theme.darkvanilla.scss index e5ebc64c5..e7949e5e1 100644 --- a/html/src/theme.darkvanilla.scss +++ b/html/src/theme.darkvanilla.scss @@ -167,12 +167,12 @@ a { } .el-checkbox__input.is-checked + .el-checkbox__label { - color: var(--theme-text) !important; + color: var(--theme-text-muted) !important; } .el-checkbox__input.is-checked .el-checkbox__inner, .el-checkbox__input.is-indeterminate .el-checkbox__inner { - border-color: var(--theme-text) !important; - background: var(--theme-text) !important; + border-color: var(--theme-text-muted) !important; + background: var(--theme-text-muted) !important; } .el-icon-star-on {