From c206ccdd00985ff411f7fb8d54a727a358137b4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Fri, 29 Mar 2024 17:28:31 -0400 Subject: [PATCH] fix: #12452, fix admin/mod image change so it doesn't update the image in the header --- public/src/modules/accounts/picture.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/public/src/modules/accounts/picture.js b/public/src/modules/accounts/picture.js index 50d869b849..d8ab277f24 100644 --- a/public/src/modules/accounts/picture.js +++ b/public/src/modules/accounts/picture.js @@ -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); }); } }