User dialog previous display names + Date friended/unfriended

This commit is contained in:
Natsumi
2022-03-27 03:18:11 +13:00
parent c1b31e1f73
commit ab7abc63a5
3 changed files with 88 additions and 10 deletions

View File

@@ -12596,7 +12596,10 @@ speechSynthesis.getVoices();
},
joinCount: 0,
timeSpent: 0,
lastSeen: ''
lastSeen: '',
previousDisplayNames: [],
dateFriended: '',
unFriended: false
};
$app.watch['userDialog.memo'] = function () {
@@ -12810,6 +12813,9 @@ speechSynthesis.getVoices();
D.lastSeen = '';
D.joinCount = 0;
D.timeSpent = 0;
D.previousDisplayNames = [];
D.dateFriended = '';
D.unFriended = false;
API.getCachedUser({
userId
})
@@ -12897,15 +12903,48 @@ speechSynthesis.getVoices();
if (this.lastLocation.playerList.has(D.ref.displayName)) {
inCurrentWorld = true;
}
database
.getUserStats(D.ref, inCurrentWorld)
.then((ref1) => {
if (userId !== API.currentUser.id) {
database
.getUserStats(D.ref, inCurrentWorld)
.then((ref1) => {
if (ref1.userId === D.id) {
D.lastSeen = ref1.created_at;
D.joinCount = ref1.joinCount;
D.timeSpent = ref1.timeSpent;
}
});
D.joinCount = ref1.joinCount;
D.timeSpent = ref1.timeSpent;
}
var displayNameMap = ref1.previousDisplayNames;
this.friendLogTable.data.forEach((ref2) => {
if (ref2.userId === D.id) {
if (ref2.type === 'DisplayName') {
displayNameMap.set(
ref2.previousDisplayName,
ref2.created_at
);
}
if (!D.dateFriended) {
if (ref2.type === 'Unfriend') {
D.unFriended = true;
D.dateFriended =
ref2.created_at;
}
if (ref2.type === 'Friend') {
D.unFriended = false;
D.dateFriended =
ref2.created_at;
}
}
}
});
var displayNameMapSorted = new Map(
[...displayNameMap.entries()].sort(
(a, b) => b[1] - a[1]
)
);
D.previousDisplayNames = Array.from(
displayNameMapSorted.keys()
);
});
}
}
return args;
});

View File

@@ -1396,6 +1396,13 @@ html
span(v-else-if="userDialog.ref.status === 'busy'") Do Not Disturb
span(v-else) Offline
i.x-user-status(:class="userStatusClass(userDialog.ref)")
template(v-if="userDialog.previousDisplayNames.length > 0")
el-tooltip(placement="bottom")
template(#content)
span Previous Display Names:
div(v-for="displayName in userDialog.previousDisplayNames" placement="top")
span(v-text="displayName")
i.el-icon-caret-bottom
span(v-text="userDialog.ref.displayName" style="margin-left:5px;margin-right:5px;font-weight:bold")
el-popover(placement="top" trigger="click")
span(slot="reference" v-text="userDialog.ref.username" style="margin-right:5px;color:#909399;font-family:monospace;font-size:12px;cursor:pointer")
@@ -1540,6 +1547,11 @@ html
.detail
span.name Date Joined
span.extra(v-text="userDialog.ref.date_joined")
.x-friend-item(style="cursor:default")
.detail
span.name(v-if="userDialog.unFriended") Unfriended
span.name(v-else) Friended
span.extra {{ userDialog.dateFriended | formatDate('long') }}
template(v-if="API.currentUser.id === userDialog.id")
.x-friend-item(@click="toggleAvatarCopying")
.detail

View File

@@ -880,7 +880,8 @@ class Database {
timeSpent: 0,
created_at: '',
joinCount: 0,
userId: input.id
userId: input.id,
previousDisplayNames: new Map()
};
await sqliteService.execute(
(row) => {
@@ -892,8 +893,11 @@ class Database {
ref.created_at = row[0];
}
instances.add(row[3]);
if (input.displayName !== row[4]) {
ref.previousDisplayNames.set(row[4], row[0]);
}
},
`SELECT created_at, user_id, time, location FROM gamelog_join_leave WHERE user_id = @userId OR display_name = @displayName ORDER BY id DESC`,
`SELECT created_at, user_id, time, location, display_name FROM gamelog_join_leave WHERE user_id = @userId OR display_name = @displayName ORDER BY id DESC`,
{
'@userId': input.id,
'@displayName': input.displayName
@@ -1343,6 +1347,29 @@ class Database {
}
);
}
async getpreviousDisplayNamesByUserId(ref) {
var data = new Map();
await sqliteService.execute(
(dbRow) => {
var row = {
created_at: dbRow[0],
displayName: dbRow[1]
};
if (ref.displayName !== row.displayName) {
data.set(row.displayName, row.created_at);
}
},
`SELECT created_at, display_name
FROM gamelog_join_leave
WHERE user_id = @userId
ORDER BY id DESC`,
{
'@userId': ref.id
}
);
return data;
}
}
var self = new Database();