mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-30 12:13:48 +02:00
Adjustments to handling of friend state
the endless battle
This commit is contained in:
120
html/src/app.js
120
html/src/app.js
@@ -1554,7 +1554,7 @@ speechSynthesis.getVoices();
|
|||||||
console.error('API.$on(USER) invalid args', args);
|
console.error('API.$on(USER) invalid args', args);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$app.queueUpdateFriend({ id: args.json.id, state: args.json.state });
|
$app.updateFriend({ id: args.json.id, state: args.json.state });
|
||||||
args.ref = this.applyUser(args.json);
|
args.ref = this.applyUser(args.json);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -2888,12 +2888,45 @@ speechSynthesis.getVoices();
|
|||||||
userId: json.id
|
userId: json.id
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (json.location === 'traveling') {
|
|
||||||
|
var state = 'offline';
|
||||||
|
if (json.platform === 'web') {
|
||||||
|
state = 'active';
|
||||||
|
} else if (json.platform) {
|
||||||
|
state = 'online';
|
||||||
|
}
|
||||||
|
var ref = $app.friends.get(json.id);
|
||||||
|
if (ref?.state !== state) {
|
||||||
|
if ($app.debugFriendState) {
|
||||||
|
console.log(
|
||||||
|
`Bulk friend fetch, friend state does not match ${json.displayName} from ${ref?.state} to ${state}`
|
||||||
|
);
|
||||||
|
}
|
||||||
this.getUser({
|
this.getUser({
|
||||||
userId: json.id
|
userId: json.id
|
||||||
});
|
});
|
||||||
// console.log('Fetching traveling user', json.id);
|
} else if (json.location === 'traveling') {
|
||||||
} // ?? hmm
|
if ($app.debugFriendState) {
|
||||||
|
console.log(
|
||||||
|
'Bulk friend fetch, fetching traveling user',
|
||||||
|
json
|
||||||
|
);
|
||||||
|
}
|
||||||
|
this.getUser({
|
||||||
|
userId: json.id
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// if (
|
||||||
|
// !args.params.offline &&
|
||||||
|
// json.platform !== 'web' &&
|
||||||
|
// json.location === 'offline'
|
||||||
|
// ) {
|
||||||
|
// console.log('Fetching offline user', json);
|
||||||
|
// this.getUser({
|
||||||
|
// userId: json.id
|
||||||
|
// });
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -5111,7 +5144,7 @@ speechSynthesis.getVoices();
|
|||||||
userId: content.userId
|
userId: content.userId
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
this.$emit('FRIEND:STATE', {
|
this.$emit('FRIEND:STATE', {
|
||||||
json: {
|
json: {
|
||||||
state: 'online'
|
state: 'online'
|
||||||
@@ -5120,6 +5153,7 @@ speechSynthesis.getVoices();
|
|||||||
userId: content.userId
|
userId: content.userId
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'friend-active':
|
case 'friend-active':
|
||||||
@@ -5133,7 +5167,7 @@ speechSynthesis.getVoices();
|
|||||||
userId: content.userId
|
userId: content.userId
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
this.$emit('FRIEND:STATE', {
|
this.$emit('FRIEND:STATE', {
|
||||||
json: {
|
json: {
|
||||||
state: 'active'
|
state: 'active'
|
||||||
@@ -5142,6 +5176,7 @@ speechSynthesis.getVoices();
|
|||||||
userId: content.userId
|
userId: content.userId
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'friend-offline':
|
case 'friend-offline':
|
||||||
@@ -5185,8 +5220,8 @@ speechSynthesis.getVoices();
|
|||||||
json: {
|
json: {
|
||||||
location: content.location,
|
location: content.location,
|
||||||
travelingToLocation: content.travelingToLocation,
|
travelingToLocation: content.travelingToLocation,
|
||||||
...content.user,
|
...content.user
|
||||||
state: 'online'
|
// state: 'online'
|
||||||
},
|
},
|
||||||
params: {
|
params: {
|
||||||
userId: content.userId
|
userId: content.userId
|
||||||
@@ -9196,18 +9231,18 @@ speechSynthesis.getVoices();
|
|||||||
});
|
});
|
||||||
|
|
||||||
API.$on('FRIEND:STATE', function (args) {
|
API.$on('FRIEND:STATE', function (args) {
|
||||||
$app.queueUpdateFriend({
|
$app.updateFriend({
|
||||||
id: args.params.userId,
|
id: args.params.userId,
|
||||||
state: args.json.state
|
state: args.json.state
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
API.$on('FAVORITE', function (args) {
|
API.$on('FAVORITE', function (args) {
|
||||||
$app.queueUpdateFriend({ id: args.ref.favoriteId });
|
$app.updateFriend({ id: args.ref.favoriteId });
|
||||||
});
|
});
|
||||||
|
|
||||||
API.$on('FAVORITE:@DELETE', function (args) {
|
API.$on('FAVORITE:@DELETE', function (args) {
|
||||||
$app.queueUpdateFriend({ id: args.ref.favoriteId });
|
$app.updateFriend({ id: args.ref.favoriteId });
|
||||||
});
|
});
|
||||||
|
|
||||||
API.$on('LOGIN', function () {
|
API.$on('LOGIN', function () {
|
||||||
@@ -9243,7 +9278,7 @@ speechSynthesis.getVoices();
|
|||||||
}
|
}
|
||||||
for (var [id, state] of map) {
|
for (var [id, state] of map) {
|
||||||
if (this.friends.has(id)) {
|
if (this.friends.has(id)) {
|
||||||
this.queueUpdateFriend({ id, state, origin });
|
this.updateFriend({ id, state, origin });
|
||||||
} else {
|
} else {
|
||||||
this.addFriend(id, state);
|
this.addFriend(id, state);
|
||||||
}
|
}
|
||||||
@@ -9363,28 +9398,6 @@ speechSynthesis.getVoices();
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$app.data.updateFriendQueue = [];
|
|
||||||
$app.data.updateFriendTimer = null;
|
|
||||||
|
|
||||||
$app.methods.queueUpdateFriend = function (ctx) {
|
|
||||||
this.updateFriendQueue.push(ctx);
|
|
||||||
if (this.updateFriendTimer !== null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.updateFriendTimer = workerTimers.setTimeout(() => {
|
|
||||||
var queue = [...this.updateFriendQueue];
|
|
||||||
this.updateFriendQueue = [];
|
|
||||||
this.updateFriendTimer = null;
|
|
||||||
for (var i = 0; i < queue.length; ++i) {
|
|
||||||
try {
|
|
||||||
this.updateFriend(queue[i]);
|
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, 5);
|
|
||||||
};
|
|
||||||
|
|
||||||
$app.data.updateFriendInProgress = new Map();
|
$app.data.updateFriendInProgress = new Map();
|
||||||
|
|
||||||
$app.methods.updateFriend = function (ctx) {
|
$app.methods.updateFriend = function (ctx) {
|
||||||
@@ -9394,24 +9407,6 @@ speechSynthesis.getVoices();
|
|||||||
if (typeof ctx === 'undefined') {
|
if (typeof ctx === 'undefined') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var lastOnlineDate = this.APILastOnline.get(id);
|
|
||||||
if (
|
|
||||||
stateInput &&
|
|
||||||
ctx.state !== stateInput &&
|
|
||||||
lastOnlineDate &&
|
|
||||||
lastOnlineDate > Date.now() - 1000
|
|
||||||
) {
|
|
||||||
// crappy double online fix
|
|
||||||
if (this.debugFriendState) {
|
|
||||||
console.log(
|
|
||||||
ctx.name,
|
|
||||||
new Date().toJSON(),
|
|
||||||
'userAlreadyOnline',
|
|
||||||
stateInput
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (stateInput === 'online') {
|
if (stateInput === 'online') {
|
||||||
this.APILastOnline.set(id, Date.now());
|
this.APILastOnline.set(id, Date.now());
|
||||||
ctx.pendingOffline = false;
|
ctx.pendingOffline = false;
|
||||||
@@ -9500,7 +9495,8 @@ speechSynthesis.getVoices();
|
|||||||
ctx.name,
|
ctx.name,
|
||||||
new Date().toJSON(),
|
new Date().toJSON(),
|
||||||
'pendingOfflineCheck',
|
'pendingOfflineCheck',
|
||||||
stateInput
|
stateInput,
|
||||||
|
ctx.state
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@@ -9538,35 +9534,28 @@ speechSynthesis.getVoices();
|
|||||||
$app.methods.updateFriendDelayedCheck = async function (
|
$app.methods.updateFriendDelayedCheck = async function (
|
||||||
id,
|
id,
|
||||||
ctx,
|
ctx,
|
||||||
stateInput,
|
newState,
|
||||||
location,
|
location,
|
||||||
$location_at
|
$location_at
|
||||||
) {
|
) {
|
||||||
var date = this.APILastOnline.get(id);
|
var date = this.APILastOnline.get(id);
|
||||||
if (
|
if (
|
||||||
ctx.state === 'online' &&
|
ctx.state === 'online' &&
|
||||||
(stateInput === 'active' || stateInput === 'offline') &&
|
(newState === 'active' || newState === 'offline') &&
|
||||||
date &&
|
date &&
|
||||||
date > Date.now() - 120000
|
date > Date.now() - 120000
|
||||||
) {
|
) {
|
||||||
if (this.debugFriendState) {
|
if (this.debugFriendState) {
|
||||||
console.log(
|
console.log(
|
||||||
`falsePositiveOffline ${ctx.name} currentState:${ctx.ref.state} expectedState:${stateInput}`
|
`falsePositiveOffline ${ctx.name} currentState:${ctx.ref.state} expectedState:${newState}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this.debugFriendState) {
|
if (this.debugFriendState) {
|
||||||
console.log(
|
console.log(ctx.name, 'updateFriendState', newState, ctx.state);
|
||||||
ctx.name,
|
|
||||||
new Date().toJSON(),
|
|
||||||
'updateFriendState',
|
|
||||||
stateInput,
|
|
||||||
ctx.ref.state
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
var isVIP = this.localFavoriteFriends.has(id);
|
var isVIP = this.localFavoriteFriends.has(id);
|
||||||
var newState = stateInput;
|
|
||||||
var ref = ctx.ref;
|
var ref = ctx.ref;
|
||||||
if (ctx.state !== newState && typeof ctx.ref !== 'undefined') {
|
if (ctx.state !== newState && typeof ctx.ref !== 'undefined') {
|
||||||
if (
|
if (
|
||||||
@@ -9654,6 +9643,7 @@ speechSynthesis.getVoices();
|
|||||||
this.updateOnlineFriendCoutner();
|
this.updateOnlineFriendCoutner();
|
||||||
}
|
}
|
||||||
ctx.state = newState;
|
ctx.state = newState;
|
||||||
|
ctx.ref.state = newState;
|
||||||
ctx.name = ref.displayName;
|
ctx.name = ref.displayName;
|
||||||
ctx.isVIP = isVIP;
|
ctx.isVIP = isVIP;
|
||||||
};
|
};
|
||||||
@@ -10761,7 +10751,7 @@ speechSynthesis.getVoices();
|
|||||||
$app.addFeed(feed);
|
$app.addFeed(feed);
|
||||||
database.addStatusToDatabase(feed);
|
database.addStatusToDatabase(feed);
|
||||||
}
|
}
|
||||||
if (props.bio) {
|
if (props.bio && props.bio[0] && props.bio[1]) {
|
||||||
var bio = '';
|
var bio = '';
|
||||||
var previousBio = '';
|
var previousBio = '';
|
||||||
if (props.bio[0]) {
|
if (props.bio[0]) {
|
||||||
|
|||||||
@@ -1770,7 +1770,7 @@ html
|
|||||||
span {{ $t('dialog.vrcx_updater.latest_version') }}
|
span {{ $t('dialog.vrcx_updater.latest_version') }}
|
||||||
template(#footer)
|
template(#footer)
|
||||||
el-button(v-if="(VRCXUpdateDialog.updatePending && VRCXUpdateDialog.release !== pendingVRCXInstall) || VRCXUpdateDialog.release !== appVersion" type="primary" size="small" @click="installVRCXUpdate") {{ $t('dialog.vrcx_updater.download') }}
|
el-button(v-if="(VRCXUpdateDialog.updatePending && VRCXUpdateDialog.release !== pendingVRCXInstall) || VRCXUpdateDialog.release !== appVersion" type="primary" size="small" @click="installVRCXUpdate") {{ $t('dialog.vrcx_updater.download') }}
|
||||||
el-button(v-if="VRCXUpdateDialog.updatePending" type="primary" size="small" @click="restartVRCX") {{ $t('dialog.vrcx_updater.install') }}
|
el-button(v-if="VRCXUpdateDialog.updatePending" type="primary" size="small" @click="restartVRCX(true)") {{ $t('dialog.vrcx_updater.install') }}
|
||||||
|
|
||||||
//- dialog: launch
|
//- dialog: launch
|
||||||
el-dialog.x-dialog(:before-close="beforeDialogClose" @mousedown.native="dialogMouseDown" @mouseup.native="dialogMouseUp" ref="launchDialog" :visible.sync="launchDialog.visible" :title="$t('dialog.launch.header')" width="450px")
|
el-dialog.x-dialog(:before-close="beforeDialogClose" @mousedown.native="dialogMouseDown" @mouseup.native="dialogMouseUp" ref="launchDialog" :visible.sync="launchDialog.visible" :title="$t('dialog.launch.header')" width="450px")
|
||||||
|
|||||||
@@ -216,8 +216,8 @@
|
|||||||
"application": {
|
"application": {
|
||||||
"header": "Application",
|
"header": "Application",
|
||||||
"startup": "Start at Windows startup",
|
"startup": "Start at Windows startup",
|
||||||
"minimized": "Start as minimized state",
|
"minimized": "Start minimized",
|
||||||
"tray": "Close to tray",
|
"tray": "Minimize to tray when closing",
|
||||||
"proxy": "Proxy settings"
|
"proxy": "Proxy settings"
|
||||||
},
|
},
|
||||||
"favorites": {
|
"favorites": {
|
||||||
|
|||||||
Reference in New Issue
Block a user