add original usernames to popover

pull/157/head
Aevann 2023-06-23 20:12:47 +03:00
parent 9c460e2770
commit f88d65b003
3 changed files with 17 additions and 1 deletions

View File

@ -35,7 +35,9 @@ document.addEventListener('shown.bs.popover', (e) => {
popover.getElementsByClassName('pop-banner')[0].src = author["bannerurl"]
popover.getElementsByClassName('pop-picture')[0].src = author["profile_url"]
if (author["hat"]) popover.getElementsByClassName('pop-hat')[0].src = author['hat'] + "?h=7"
if (author["hat"]) {
popover.getElementsByClassName('pop-hat')[0].src = author['hat'] + "?h=7"
}
popover.getElementsByClassName('pop-username')[0].innerHTML = author["username"]
if (popover.getElementsByClassName('pop-bio').length > 0) {
popover.getElementsByClassName('pop-bio')[0].innerHTML = author["bio_html"]
@ -47,6 +49,9 @@ document.addEventListener('shown.bs.popover', (e) => {
popover.getElementsByClassName('pop-view_more')[0].href = author["url"]
popover.getElementsByClassName('pop-created-date')[0].innerHTML = author["created_date"]
popover.getElementsByClassName('pop-id')[0].innerHTML = author["id"]
if (author["original_usernames"]) {
popover.getElementsByClassName('pop-original-usernames')[0].innerHTML = author["original_usernames"]
}
})
function post(url) {

View File

@ -859,6 +859,15 @@ class User(Base):
if v and (v.id == self.id or v.can_see_shadowbanned): return self.comment_count
return 0
@property
@lazy
def original_usernames_popover(self):
if self.username == self.original_username:
return ''
names = {self.original_username}
if self.prelock_username:
names.add(self.prelock_username)
return 'Original Usernames: @' + ', @'.join(names)
@lazy
def json_popover(self, v):
@ -875,6 +884,7 @@ class User(Base):
'comment_count': self.real_comment_count(v),
'badges': [x.path for x in self.badges],
'created_date': self.created_date,
'original_usernames': self.original_usernames_popover,
}
return data

View File

@ -10,6 +10,7 @@
<h5 class="pop-username text-truncate text-black mb-0 pb-1 mt-4 pt-2"></h5>
<span class="text-black">Joined <span class="pop-created-date"></span></span>
<div class="text-black">User ID: <span class="pop-id"></span></div>
<div class="text-black"><span class="pop-original-usernames"></span></div>
</div>
</div>