fix: #12452, fix admin/mod image change

so it doesn't update the image in the header
This commit is contained in:
Barış Soner Uşaklı
2024-03-29 17:28:31 -04:00
parent 277e17876a
commit c206ccdd00

View File

@@ -94,7 +94,10 @@ define('accounts/picture', [
const iconBgColor = document.querySelector('.modal.picture-switcher input[type="radio"]:checked').value || 'transparent';
changeUserPicture(type, iconBgColor).then(() => {
Picture.updateHeader(type === 'default' ? '' : modal.find('.list-group-item.active img').attr('src'), iconBgColor);
Picture.updateHeader(
type === 'default' ? '' : modal.find('.list-group-item.active img').attr('src'),
iconBgColor
);
ajaxify.refresh();
}).catch(alerts.error);
}
@@ -139,16 +142,17 @@ define('accounts/picture', [
function handleImageUpload(modal) {
function onUploadComplete(urlOnServer) {
urlOnServer = (!urlOnServer.startsWith('http') ? config.relative_path : '') + urlOnServer + '?' + Date.now();
Picture.updateHeader(urlOnServer);
urlOnServer = (!urlOnServer.startsWith('http') ? config.relative_path : '') + urlOnServer;
const cacheBustedUrl = urlOnServer + '?' + Date.now();
Picture.updateHeader(cacheBustedUrl);
if (ajaxify.data.picture && ajaxify.data.picture.length) {
$('#user-current-picture, img.avatar').attr('src', urlOnServer);
$(`#user-current-picture, img[data-uid="${ajaxify.data.theirid}"].avatar`).attr('src', cacheBustedUrl);
ajaxify.data.uploadedpicture = urlOnServer;
ajaxify.data.picture = urlOnServer;
} else {
ajaxify.refresh(function () {
$('#user-current-picture, img.avatar').attr('src', urlOnServer);
$(`#user-current-picture, img[data-uid="${ajaxify.data.theirid}"].avatar`).attr('src', cacheBustedUrl);
});
}
}