refactor: not all themes have header

user a more specific selector that only updates the correct avatars using user id
This commit is contained in:
Barış Soner Uşaklı
2023-01-13 20:51:06 -05:00
parent 4164d51e08
commit b537ba587b
2 changed files with 8 additions and 5 deletions

View File

@@ -55,6 +55,7 @@
"account/watched_categories": "%1's Watched Categories",
"account/bookmarks": "%1's Bookmarked Posts",
"account/settings": "User Settings",
"account/settings-of": "Changing settings of %1",
"account/watched": "Topics watched by %1",
"account/ignored": "Topics ignored by %1",
"account/upvoted": "Posts upvoted by %1",

View File

@@ -113,15 +113,17 @@ define('accounts/picture', [
if (!picture && ajaxify.data.defaultAvatar) {
picture = ajaxify.data.defaultAvatar;
}
$('#header [component="avatar/picture"]')[picture ? 'show' : 'hide']();
$('#header [component="avatar/icon"]')[!picture ? 'show' : 'hide']();
const pictureEl = $(`[component="avatar/picture"][data-uid=${ajaxify.data.uid}]`);
const iconEl = $(`[component="avatar/icon"][data-uid=${ajaxify.data.uid}]`);
pictureEl[picture ? 'show' : 'hide']();
iconEl[!picture ? 'show' : 'hide']();
if (picture) {
$('#header [component="avatar/picture"]').attr('src', picture);
pictureEl.attr('src', picture);
}
if (iconBgColor) {
document.querySelectorAll('[component="navbar"] [component="avatar/icon"]').forEach((el) => {
el.style['background-color'] = iconBgColor;
iconEl.css({
'background-color': iconBgColor,
});
}
};