Make use of queuedInstance to add/remove queued instances

This commit is contained in:
Natsumi
2023-12-04 20:51:46 +13:00
parent 00e93a9667
commit 704268bb1b
3 changed files with 64 additions and 15 deletions

View File

@@ -1637,6 +1637,7 @@ speechSynthesis.getVoices();
this.applyUserTrustLevel(ref); this.applyUserTrustLevel(ref);
this.applyUserLanguage(ref); this.applyUserLanguage(ref);
this.applyPresenceLocation(ref); this.applyPresenceLocation(ref);
this.applyQueuedInstance(ref.queuedInstance);
// update group list // update group list
if (json.presence?.groups) { if (json.presence?.groups) {
for (var groupId of json.presence.groups) { for (var groupId of json.presence.groups) {
@@ -1663,6 +1664,7 @@ speechSynthesis.getVoices();
currentAvatar: '', currentAvatar: '',
currentAvatarAssetUrl: '', currentAvatarAssetUrl: '',
currentAvatarImageUrl: '', currentAvatarImageUrl: '',
currentAvatarTags: [],
currentAvatarThumbnailImageUrl: '', currentAvatarThumbnailImageUrl: '',
date_joined: '', date_joined: '',
developerType: '', developerType: '',
@@ -1672,10 +1674,12 @@ speechSynthesis.getVoices();
friendGroupNames: [], friendGroupNames: [],
friendKey: '', friendKey: '',
friends: [], friends: [],
googleId: '',
hasBirthday: false, hasBirthday: false,
hasEmail: false, hasEmail: false,
hasLoggedInFromClient: false, hasLoggedInFromClient: false,
hasPendingEmail: false, hasPendingEmail: false,
hideContentFilterSettings: false,
homeLocation: '', homeLocation: '',
id: '', id: '',
isFriend: false, isFriend: false,
@@ -1688,8 +1692,10 @@ speechSynthesis.getVoices();
offlineFriends: [], offlineFriends: [],
onlineFriends: [], onlineFriends: [],
pastDisplayNames: [], pastDisplayNames: [],
picoId: '',
presence: { presence: {
avatarThumbnail: '', avatarThumbnail: '',
currentAvatarTags: '',
displayName: '', displayName: '',
groups: [], groups: [],
id: '', id: '',
@@ -1700,10 +1706,12 @@ speechSynthesis.getVoices();
status: '', status: '',
travelingToInstance: '', travelingToInstance: '',
travelingToWorld: '', travelingToWorld: '',
userIcon: '',
world: '', world: '',
...json.presence ...json.presence
}, },
profilePicOverride: '', profilePicOverride: '',
queuedInstance: '',
state: '', state: '',
status: '', status: '',
statusDescription: '', statusDescription: '',
@@ -1717,7 +1725,10 @@ speechSynthesis.getVoices();
unsubscribe: false, unsubscribe: false,
updated_at: '', updated_at: '',
userIcon: '', userIcon: '',
userLanguage: '',
userLanguageCode: '',
username: '', username: '',
viveId: '',
// VRCX // VRCX
$online_for: Date.now(), $online_for: Date.now(),
$offline_for: '', $offline_for: '',
@@ -26834,6 +26845,10 @@ speechSynthesis.getVoices();
$app.methods.removeAllQueuedInstances = function () { $app.methods.removeAllQueuedInstances = function () {
API.queuedInstances.forEach((ref) => { API.queuedInstances.forEach((ref) => {
this.$message({
message: `Removed instance ${ref.$worldName} from queue`,
type: 'info'
});
ref.$msgBox?.close(); ref.$msgBox?.close();
}); });
API.queuedInstances.clear(); 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) { $app.methods.instanceQueueReady = function (instanceId) {
var ref = API.queuedInstances.get(instanceId); var ref = API.queuedInstances.get(instanceId);
if (typeof ref !== 'undefined') { 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} `; ref.$msgBox.message = `You are in position ${ref.position} of ${ref.queueSize} in the queue for ${displayLocation} `;
API.queuedInstances.set(instanceId, ref); API.queuedInstances.set(instanceId, ref);
workerTimers.setTimeout(this.instanceQueueTimeout, 3600000); // workerTimers.setTimeout(this.instanceQueueTimeout, 3600000);
}; };
$app.methods.instanceQueueTimeout = function () { // $app.methods.instanceQueueTimeout = function () {
// remove instance from queue after 1hour of inactivity // // remove instance from queue after 1hour of inactivity
API.queuedInstances.forEach((ref) => { // API.queuedInstances.forEach((ref) => {
// 59mins // // 59mins
if (Date.now() - ref.updatedAt > 3540000) { // if (Date.now() - ref.updatedAt > 3540000) {
ref.$msgBox.close(); // ref.$msgBox.close();
API.queuedInstances.delete(ref.location); // API.queuedInstances.delete(ref.location);
} // }
}); // });
}; // };
/** /**
* @param {{ groupId: string }} params * @param {{ groupId: string }} params

View File

@@ -323,7 +323,7 @@
"when_to_display_game_closed": "Game Closed", "when_to_display_game_closed": "Game Closed",
"when_to_display_game_running": "Game Running", "when_to_display_game_running": "Game Running",
"when_to_display_always": "Always", "when_to_display_always": "Always",
"desktop_notification_while_afk": "Desktop Notification While AFK" "desktop_notification_while_afk": "Desktop Notifications While AFK"
}, },
"text_to_speech": { "text_to_speech": {
"header": "Text-To-Speech Options", "header": "Text-To-Speech Options",

View File

@@ -167,12 +167,12 @@ a {
} }
.el-checkbox__input.is-checked + .el-checkbox__label { .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-checked .el-checkbox__inner,
.el-checkbox__input.is-indeterminate .el-checkbox__inner { .el-checkbox__input.is-indeterminate .el-checkbox__inner {
border-color: var(--theme-text) !important; border-color: var(--theme-text-muted) !important;
background: var(--theme-text) !important; background: var(--theme-text-muted) !important;
} }
.el-icon-star-on { .el-icon-star-on {