fix: autorefresh logs
Signed-off-by: Omar Sánchez Pizarro <omar.sanchez@pistacero.net>
This commit is contained in:
@@ -121,12 +121,17 @@ async function loadLogs(forceReload = false, shouldScroll = null) {
|
|||||||
const previousScrollTop = logsContainer.value?.scrollTop || 0;
|
const previousScrollTop = logsContainer.value?.scrollTop || 0;
|
||||||
const previousScrollHeight = logsContainer.value?.scrollHeight || 0;
|
const previousScrollHeight = logsContainer.value?.scrollHeight || 0;
|
||||||
|
|
||||||
|
// Solo mostrar loader en carga inicial o recarga forzada
|
||||||
|
const isInitialLoad = logs.value.length === 0 || lastLoadedLogHash.value === null;
|
||||||
|
if (forceReload || isInitialLoad) {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const data = await api.getLogs(500);
|
const data = await api.getLogs(500);
|
||||||
const newLogs = data.logs || [];
|
const newLogs = data.logs || [];
|
||||||
|
|
||||||
if (forceReload || logs.value.length === 0 || lastLoadedLogHash.value === null) {
|
if (forceReload || isInitialLoad) {
|
||||||
// Carga inicial o recarga forzada: reemplazar todo
|
// Carga inicial o recarga forzada: reemplazar todo
|
||||||
logs.value = newLogs;
|
logs.value = newLogs;
|
||||||
lastLoadedLogHash.value = newLogs.length > 0 ? hashLog(newLogs[newLogs.length - 1]) : null;
|
lastLoadedLogHash.value = newLogs.length > 0 ? hashLog(newLogs[newLogs.length - 1]) : null;
|
||||||
@@ -188,8 +193,13 @@ async function loadLogs(forceReload = false, shouldScroll = null) {
|
|||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error cargando logs:', error);
|
console.error('Error cargando logs:', error);
|
||||||
} finally {
|
// Asegurar que el loader se oculte incluso si hay error
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
|
} finally {
|
||||||
|
// Solo ocultar loader si se mostró
|
||||||
|
if (forceReload || isInitialLoad) {
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user