mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-06-06 03:34:40 +00:00
feat: performance improvements to profile picture plugin
This commit is contained in:
@@ -43,6 +43,7 @@
|
|||||||
const newBlobUrl = URL.createObjectURL(file)
|
const newBlobUrl = URL.createObjectURL(file)
|
||||||
value = newBlobUrl
|
value = newBlobUrl
|
||||||
blobUrl = newBlobUrl
|
blobUrl = newBlobUrl
|
||||||
|
window.dispatchEvent(new Event('profile-picture-updated'))
|
||||||
}
|
}
|
||||||
|
|
||||||
function onFileChange() {
|
function onFileChange() {
|
||||||
@@ -62,6 +63,7 @@
|
|||||||
}
|
}
|
||||||
value = undefined
|
value = undefined
|
||||||
await store.removeItem('profile-picture')
|
await store.removeItem('profile-picture')
|
||||||
|
window.dispatchEvent(new Event('profile-picture-updated'))
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -69,11 +69,12 @@ const profilePicturePlugin: Plugin<typeof settings> = {
|
|||||||
// Initial load
|
// Initial load
|
||||||
await updateImageFromStore();
|
await updateImageFromStore();
|
||||||
|
|
||||||
// Listen for storage changes (in case user updates from settings)
|
// Listen for profile picture updates
|
||||||
const interval = setInterval(updateImageFromStore, 1000);
|
const handler = () => { updateImageFromStore(); };
|
||||||
|
window.addEventListener('profile-picture-updated', handler);
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
clearInterval(interval);
|
window.removeEventListener('profile-picture-updated', handler);
|
||||||
if (img) img.remove();
|
if (img) img.remove();
|
||||||
if (svg) svg.style.display = "";
|
if (svg) svg.style.display = "";
|
||||||
if (currentBlobUrl) URL.revokeObjectURL(currentBlobUrl);
|
if (currentBlobUrl) URL.revokeObjectURL(currentBlobUrl);
|
||||||
|
|||||||
Reference in New Issue
Block a user