UI - Favicons - Realtime mode - Fixing small bug when favicon needed updating in realtime

pull/3162/merge
dgtlmoon 2025-07-09 16:41:32 +02:00
rodzic 2f7520a6c5
commit 55cdcfe3ea
2 zmienionych plików z 6 dodań i 5 usunięć

Wyświetl plik

@ -146,7 +146,7 @@ document.addEventListener('DOMContentLoaded', function() {
<td class="title-col inline">
<div class="flex-wrapper">
<div>{# A page might have hundreds of these images, set IMG options for lazy loading, don't set SRC if we dont have it so it doesnt fetch the placeholder' #}
<img alt="Favicon thumbnail" style="display: none;" class="favicon" loading="lazy" decoding="async" fetchpriority="low" {% if has_favicon %} src="{{url_for('static_content', group='favicon', filename=watch.uuid)}}"{% endif %} />
<img alt="Favicon thumbnail" style="display: none;" class="favicon" loading="lazy" decoding="async" fetchpriority="low" {% if has_favicon %} src="{{url_for('static_content', group='favicon', filename=watch.uuid)}}" {% else %} src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw=="{% endif %} />
</div>
<div>
<span class="watch-title">

Wyświetl plik

@ -105,14 +105,15 @@ $(document).ready(function () {
});
// So that the favicon is only updated when the server has written the scraped favicon to disk.
socket.on('watch_bumped_favicon', function (data) {
const watch = data.watch;
const $watchRow = $('tr[data-watch-uuid="' + watch.uuid + '"]');
socket.on('watch_bumped_favicon', function (watch) {
const $watchRow = $(`tr[data-watch-uuid="${watch.uuid}"]`);
if ($watchRow.length) {
$watchRow.addClass('has-favicon');
// Because the event could be emitted from a process that is outside the app context, url_for() might not work.
// Lets use url_for at template generation time to give us a PLACEHOLDER instead
$('img.favicon', $watchRow).attr('src', favicon_baseURL.replace('/PLACEHOLDER', `/${watch.uuid}?cache=${watch.event_timestamp}`));
let favicon_url = favicon_baseURL.replace('/PLACEHOLDER', `/${watch.uuid}?cache=${watch.event_timestamp}`);
console.log(`Setting favicon for UUID - ${watch.uuid} - ${favicon_url}`);
$('img.favicon', $watchRow).attr('src', favicon_url);
}
})