Verify friend/unfriends

This commit is contained in:
Natsumi
2022-02-12 19:28:33 +13:00
parent 1b135e1f15
commit 33a8b079ab
+21 -10
View File
@@ -10467,28 +10467,25 @@ speechSynthesis.getVoices();
if (!this.friendLogInitStatus || this.friendLog.has(id)) {
return;
}
var ctx = {
id,
displayName: null,
trustLevel: null
};
var ref = API.cachedUsers.get(id);
if (typeof ref !== 'undefined') {
ctx.displayName = ref.displayName;
ctx.trustLevel = ref.$trustLevel;
API.getFriendStatus({
userId: id
}).then((args) => {
if (args.json.isFriend) {
var friendLogHistory = {
created_at: new Date().toJSON(),
type: 'Friend',
userId: id,
displayName: ctx.displayName
displayName: ref.displayName
};
this.friendLogTable.data.push(friendLogHistory);
database.addFriendLogHistory(friendLogHistory);
this.queueFriendLogNoty(friendLogHistory);
var friendLogCurrent = {
userId: id,
displayName: ctx.displayName,
trustLevel: ctx.trustLevel
displayName: ref.displayName,
trustLevel: ref.$trustLevel
};
this.friendLog.set(id, friendLogCurrent);
database.setFriendLogCurrent(friendLogCurrent);
@@ -10496,6 +10493,8 @@ speechSynthesis.getVoices();
this.deleteFriendRequest(id);
this.updateSharedFeed(true);
}
});
}
};
$app.methods.deleteFriendRequest = function (userId) {
@@ -10516,6 +10515,10 @@ speechSynthesis.getVoices();
if (typeof ctx === 'undefined') {
return;
}
API.getFriendStatus({
userId: id
}).then((args) => {
if (!args.json.isFriend) {
var friendLogHistory = {
created_at: new Date().toJSON(),
type: 'Unfriend',
@@ -10529,6 +10532,8 @@ speechSynthesis.getVoices();
database.deleteFriendLogCurrent(id);
this.notifyMenu('friendLog');
this.updateSharedFeed(true);
}
});
};
$app.methods.updateFriendships = function (ref) {
@@ -10553,6 +10558,10 @@ speechSynthesis.getVoices();
return;
}
if (ctx.displayName !== ref.displayName) {
API.getFriendStatus({
userId: ref.id
}).then((args) => {
if (args.json.isFriend) {
if (ctx.displayName) {
var friendLogHistory = {
created_at: new Date().toJSON(),
@@ -10583,6 +10592,8 @@ speechSynthesis.getVoices();
this.notifyMenu('friendLog');
this.updateSharedFeed(true);
}
});
}
if (
ref.$trustLevel &&
ctx.trustLevel &&