Skip to content

Commit

Permalink
Make use of queuedInstance to add/remove queued instances
Browse files Browse the repository at this point in the history
  • Loading branch information
Natsumi-sama committed Dec 4, 2023
1 parent 00e93a9 commit 704268b
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 15 deletions.
71 changes: 60 additions & 11 deletions html/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -1663,6 +1664,7 @@ speechSynthesis.getVoices();
currentAvatar: '',
currentAvatarAssetUrl: '',
currentAvatarImageUrl: '',
currentAvatarTags: [],
currentAvatarThumbnailImageUrl: '',
date_joined: '',
developerType: '',
Expand All @@ -1672,10 +1674,12 @@ speechSynthesis.getVoices();
friendGroupNames: [],
friendKey: '',
friends: [],
googleId: '',
hasBirthday: false,
hasEmail: false,
hasLoggedInFromClient: false,
hasPendingEmail: false,
hideContentFilterSettings: false,
homeLocation: '',
id: '',
isFriend: false,
Expand All @@ -1688,8 +1692,10 @@ speechSynthesis.getVoices();
offlineFriends: [],
onlineFriends: [],
pastDisplayNames: [],
picoId: '',
presence: {
avatarThumbnail: '',
currentAvatarTags: '',
displayName: '',
groups: [],
id: '',
Expand All @@ -1700,10 +1706,12 @@ speechSynthesis.getVoices();
status: '',
travelingToInstance: '',
travelingToWorld: '',
userIcon: '',
world: '',
...json.presence
},
profilePicOverride: '',
queuedInstance: '',
state: '',
status: '',
statusDescription: '',
Expand All @@ -1717,7 +1725,10 @@ speechSynthesis.getVoices();
unsubscribe: false,
updated_at: '',
userIcon: '',
userLanguage: '',
userLanguageCode: '',
username: '',
viveId: '',
// VRCX
$online_for: Date.now(),
$offline_for: '',
Expand Down Expand Up @@ -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();
Expand All @@ -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') {
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion html/src/localization/en/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions html/src/theme.darkvanilla.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 704268b

Please sign in to comment.