Fix double display name change

This commit is contained in:
Natsumi
2022-03-09 17:23:45 +13:00
parent 40dfb248de
commit 852e6504ff

View File

@@ -10663,26 +10663,38 @@ speechSynthesis.getVoices();
return; return;
} }
if (ctx.displayName !== ref.displayName) { if (ctx.displayName !== ref.displayName) {
if (ctx.displayName) {
var friendLogHistory = {
created_at: new Date().toJSON(),
type: 'DisplayName',
userId: ref.id,
displayName: ref.displayName,
previousDisplayName: ctx.displayName
};
this.friendLogTable.data.push(friendLogHistory);
database.addFriendLogHistory(friendLogHistory);
this.queueFriendLogNoty(friendLogHistory);
var friendLogCurrent = {
userId: ref.id,
displayName: ref.displayName,
trustLevel: ref.$trustLevel
};
this.friendLog.set(ref.id, friendLogCurrent);
database.setFriendLogCurrent(friendLogCurrent);
ctx.displayName = ref.displayName;
this.notifyMenu('friendLog');
this.updateSharedFeed(true);
}
API.getFriendStatus({ API.getFriendStatus({
userId: ref.id userId: ref.id
}).then((args) => { }).then((args) => {
if (args.json.isFriend && this.friendLog.has(ref.id)) { if (args.json.isFriend && this.friendLog.has(ref.id) && !ctx.displayName) {
if (ctx.displayName) { var friendLogHistory = {
var friendLogHistory = { created_at: new Date().toJSON(),
created_at: new Date().toJSON(), type: 'Friend',
type: 'DisplayName', userId: ref.id,
userId: ref.id, displayName: ref.displayName
displayName: ref.displayName, };
previousDisplayName: ctx.displayName
};
} else {
var friendLogHistory = {
created_at: new Date().toJSON(),
type: 'Friend',
userId: ref.id,
displayName: ref.displayName
};
}
this.friendLogTable.data.push(friendLogHistory); this.friendLogTable.data.push(friendLogHistory);
database.addFriendLogHistory(friendLogHistory); database.addFriendLogHistory(friendLogHistory);
this.queueFriendLogNoty(friendLogHistory); this.queueFriendLogNoty(friendLogHistory);