@songsid/agend 2.0.11-beta.42 → 2.0.11-beta.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ui/view.html +17 -3
- package/package.json +1 -1
package/dist/ui/view.html
CHANGED
|
@@ -395,11 +395,25 @@
|
|
|
395
395
|
const box = q("avatarBox");
|
|
396
396
|
if (it.has_avatar) {
|
|
397
397
|
const base = api(`/api/avatar/${encodeURIComponent(it.instance_name)}`);
|
|
398
|
-
|
|
399
|
-
|
|
398
|
+
// Only rebuild (and cache-bust) when the avatar's instance changed.
|
|
399
|
+
// Rebuilding every renderCard re-issued the <img> request each 5s
|
|
400
|
+
// loadRoster tick, which made the avatar flicker. Compare the raw src
|
|
401
|
+
// attribute (relative, as set) rather than img.src (resolved absolute).
|
|
402
|
+
const existingImg = box.querySelector("img");
|
|
403
|
+
const cur = existingImg ? (existingImg.getAttribute("src") || "") : "";
|
|
404
|
+
// The delimiter (base+"?" / base+"&") prevents a prefix collision between
|
|
405
|
+
// e.g. ".../foo" and ".../foobar".
|
|
406
|
+
const sameAvatar = existingImg && (cur.startsWith(base + "?") || cur.startsWith(base + "&"));
|
|
407
|
+
if (!sameAvatar) {
|
|
408
|
+
const src = base + (base.includes("?") ? "&" : "?") + "t=" + Date.now(); // cache-bust, correct query separator
|
|
409
|
+
box.innerHTML = `<img class="avatar-img" alt="" src="${src}">`;
|
|
410
|
+
}
|
|
400
411
|
} else {
|
|
401
412
|
const initial = (it.display_name || it.instance_name || "?").trim().charAt(0) || "?";
|
|
402
|
-
|
|
413
|
+
const ph = box.querySelector(".avatar-ph");
|
|
414
|
+
if (!ph || ph.textContent !== initial) {
|
|
415
|
+
box.innerHTML = `<div class="avatar-ph">${esc(initial)}</div>`;
|
|
416
|
+
}
|
|
403
417
|
}
|
|
404
418
|
}
|
|
405
419
|
|