Fix new friend delay

This commit is contained in:
Natsumi
2022-08-12 21:40:34 +12:00
parent e45410191c
commit e63a734fcd
+19 -31
View File
@@ -10784,6 +10784,14 @@ speechSynthesis.getVoices();
API.$on('USER', function (args) { API.$on('USER', function (args) {
$app.updateFriendship(args.ref); $app.updateFriendship(args.ref);
if (
$app.friendLogInitStatus &&
args.json.isFriend &&
!$app.friendLog.has(args.ref.id) &&
args.json.id !== this.currentUser.id
) {
$app.addFriendship(args.ref.id);
}
}); });
API.$on('FRIEND:ADD', function (args) { API.$on('FRIEND:ADD', function (args) {
@@ -10882,11 +10890,17 @@ speechSynthesis.getVoices();
return; return;
} }
var ref = API.cachedUsers.get(id); var ref = API.cachedUsers.get(id);
if (typeof ref !== 'undefined') { if (typeof ref === 'undefined') {
API.getUser({
userId: id
});
return;
}
API.getFriendStatus({ API.getFriendStatus({
userId: id userId: id
}).then((args) => { }).then((args) => {
if (args.json.isFriend && !this.friendLog.has(id)) { if (args.json.isFriend && !this.friendLog.has(id)) {
this.addFriend(id, ref.state);
var friendLogHistory = { var friendLogHistory = {
created_at: new Date().toJSON(), created_at: new Date().toJSON(),
type: 'Friend', type: 'Friend',
@@ -10906,9 +10920,11 @@ speechSynthesis.getVoices();
this.notifyMenu('friendLog'); this.notifyMenu('friendLog');
this.deleteFriendRequest(id); this.deleteFriendRequest(id);
this.updateSharedFeed(true); this.updateSharedFeed(true);
} API.getUser({
userId: id
}); });
} }
});
}; };
$app.methods.deleteFriendRequest = function (userId) { $app.methods.deleteFriendRequest = function (userId) {
@@ -10946,6 +10962,7 @@ speechSynthesis.getVoices();
database.deleteFriendLogCurrent(id); database.deleteFriendLogCurrent(id);
this.notifyMenu('friendLog'); this.notifyMenu('friendLog');
this.updateSharedFeed(true); this.updateSharedFeed(true);
this.deleteFriend(id);
} }
}); });
}; };
@@ -10994,35 +11011,6 @@ speechSynthesis.getVoices();
this.notifyMenu('friendLog'); this.notifyMenu('friendLog');
this.updateSharedFeed(true); this.updateSharedFeed(true);
} }
API.getFriendStatus({
userId: ref.id
}).then((args) => {
if (
args.json.isFriend &&
this.friendLog.has(ref.id) &&
!ctx.displayName
) {
var friendLogHistoryFriend = {
created_at: new Date().toJSON(),
type: 'Friend',
userId: ref.id,
displayName: ref.displayName
};
this.friendLogTable.data.push(friendLogHistoryFriend);
database.addFriendLogHistory(friendLogHistoryFriend);
this.queueFriendLogNoty(friendLogHistoryFriend);
var friendLogCurrent1 = {
userId: ref.id,
displayName: ref.displayName,
trustLevel: ref.$trustLevel
};
this.friendLog.set(ref.id, friendLogCurrent1);
database.setFriendLogCurrent(friendLogCurrent1);
ctx.displayName = ref.displayName;
this.notifyMenu('friendLog');
this.updateSharedFeed(true);
}
});
} }
if ( if (
ref.$trustLevel && ref.$trustLevel &&