Group instances

This commit is contained in:
Natsumi
2023-06-02 21:22:31 +12:00
parent ada39a05a7
commit fc4d94c279
4 changed files with 97 additions and 5 deletions

View File

@@ -408,7 +408,12 @@ speechSynthesis.getVoices();
if (response.status === 200) {
this.$throw(0, 'Invalid JSON response');
}
if (response.status === 504 || response.status === 502) {
if (
response.status === 504 ||
response.status === 502 ||
(response.status === 429 &&
init.url.endswith('/instances/groups '))
) {
// ignore expected API errors
throw new Error(
`${response.status}: ${response.data} ${endpoint}`
@@ -484,9 +489,6 @@ speechSynthesis.getVoices();
) {
throw new Error(`403: ${data.error.message} ${endpoint}`);
}
if (status === 429) {
throw new Error(`429: ${data.error.message} ${endpoint}`);
}
if (data && data.error === Object(data.error)) {
this.$throw(
data.error.status_code || status,
@@ -5041,6 +5043,7 @@ speechSynthesis.getVoices();
API,
nextCurrentUserRefresh: 0,
nextFriendsRefresh: 0,
nextGroupInstanceRefresh: 0,
nextAppUpdateCheck: 7200,
ipcTimeout: 0,
nextClearVRCXCacheCheck: 0,
@@ -5219,6 +5222,12 @@ speechSynthesis.getVoices();
});
AppApi.CheckGameRunning();
}
if (--this.nextGroupInstanceRefresh <= 0) {
if (this.friendLogInitStatus) {
this.nextGroupInstanceRefresh = 600; // 5min
API.getUsersGroupInstances();
}
}
if (--this.nextAppUpdateCheck <= 0) {
if (this.branch === 'Stable') {
this.nextAppUpdateCheck = 14400; // 2hours
@@ -7585,6 +7594,8 @@ speechSynthesis.getVoices();
$app.data.isFriendsGroup1 = true;
$app.data.isFriendsGroup2 = true;
$app.data.isFriendsGroup3 = false;
$app.data.isGroupInstances = false;
$app.data.groupInstances = [];
$app.data.friendsGroup0_ = [];
$app.data.friendsGroup1_ = [];
$app.data.friendsGroup2_ = [];
@@ -10543,6 +10554,15 @@ speechSynthesis.getVoices();
}
});
}
} else if (data.Parameters[245]['0'] === 13) {
var msg = data.Parameters[245]['2'];
this.addEntryPhotonEvent({
photonId,
text: msg,
type: 'Moderation',
color: 'yellow',
created_at: gameLogDate
});
}
break;
case 202:
@@ -25128,6 +25148,46 @@ speechSynthesis.getVoices();
});
};
API.$on('GROUP:USER:INSTANCES', function (args) {
$app.groupInstances = [];
for (var json of args.json.instances) {
this.$emit('INSTANCE', {
json,
params: {
fetchedAt: args.json.fetchedAt
}
});
var ref = this.cachedGroups.get(json.ownerId);
if (typeof ref === 'undefined') {
if ($app.friendLogInitStatus) {
this.getGroup({ groupId: json.ownerId });
}
return;
}
$app.groupInstances.push({
$group: ref,
...json
});
}
});
API.$on('INSTANCE', function (args) {
var { json } = args;
if (!json) {
return;
}
for (var instance of $app.groupInstances) {
if (instance.id === json.id) {
instance = {
...instance,
...json
};
break;
}
}
});
/*
params: {
query: string,