Pending offline check user state

This commit is contained in:
Natsumi
2022-08-28 23:52:35 +12:00
parent a7e14370d9
commit fd4507fc43
4 changed files with 35 additions and 13 deletions

View File

@@ -6537,6 +6537,7 @@ speechSynthesis.getVoices();
name: '',
no: ++this.friendsNo,
memo: '',
pendingOffline: false,
$nickName: ''
};
if (this.friendLogInitStatus) {
@@ -6629,6 +6630,7 @@ speechSynthesis.getVoices();
}
if (stateInput === 'online') {
this.APILastOnline.set(id, Date.now());
ctx.pendingOffline = false;
}
var ref = API.cachedUsers.get(id);
var isVIP = API.cachedFavoritesByObjectId.has(id);
@@ -6714,6 +6716,9 @@ speechSynthesis.getVoices();
ctx.state === 'online' &&
(stateInput === 'active' || stateInput === 'offline')
) {
ctx.ref = ref;
ctx.isVIP = isVIP;
ctx.name = ref.displayName;
// delayed second check to prevent status flapping
var date = this.updateFriendInProgress.get(id);
if (date && date > Date.now() - 120000) {
@@ -6728,9 +6733,11 @@ speechSynthesis.getVoices();
}
return;
}
ctx.pendingOffline = true;
this.updateFriendInProgress.set(id, Date.now());
// wait 2minutes then check if user came back online
workerTimers.setTimeout(() => {
ctx.pendingOffline = false;
this.updateFriendInProgress.delete(id);
this.updateFriendDelayedCheck(
id,
@@ -6742,6 +6749,9 @@ speechSynthesis.getVoices();
);
}, 110000);
} else {
ctx.ref = ref;
ctx.isVIP = isVIP;
ctx.name = ref.displayName;
this.updateFriendDelayedCheck(
id,
ctx,
@@ -6773,7 +6783,8 @@ speechSynthesis.getVoices();
ctx.name,
new Date().toJSON(),
'falsePositiveOffline',
stateInput
stateInput,
ctx.ref.state
);
}
return;
@@ -6788,8 +6799,8 @@ speechSynthesis.getVoices();
ctx.name,
new Date().toJSON(),
'updateFriendState',
newState,
stateInput
stateInput,
ctx.ref.state
);
}
var newRef = args.ref;
@@ -7145,7 +7156,7 @@ speechSynthesis.getVoices();
return this.friendsGroup3_;
};
$app.methods.userStatusClass = function (user) {
$app.methods.userStatusClass = function (user, pendingOffline) {
var style = {};
if (typeof user !== 'undefined') {
var id = '';
@@ -7160,14 +7171,17 @@ speechSynthesis.getVoices();
if (!user.isFriend) {
return '';
}
// temp fix
if (
if (pendingOffline) {
// Pending offline
style.offline = true;
} else if (
user.status !== 'active' &&
user.location === 'private' &&
user.state === '' &&
id &&
!API.currentUser.onlineFriends.includes(id)
) {
// temp fix
if (API.currentUser.activeFriends.includes(id)) {
// Active
style.active = true;