From e551ad7848d6bc84c577632d3d8bbf20aa8cf8c8 Mon Sep 17 00:00:00 2001 From: arabcoders Date: Thu, 22 Jan 2026 23:00:45 +0300 Subject: [PATCH] refactor: improve connection status and history loading logic --- ui/app/components/Connection.vue | 2 +- ui/app/components/History.vue | 2 +- ui/app/components/Simple.vue | 17 ++++++++--------- ui/app/layouts/default.vue | 26 ++++++++++++++++---------- 4 files changed, 26 insertions(+), 21 deletions(-) diff --git a/ui/app/components/Connection.vue b/ui/app/components/Connection.vue index 2aa7587e..4b027036 100644 --- a/ui/app/components/Connection.vue +++ b/ui/app/components/Connection.vue @@ -3,7 +3,7 @@
- Connection lost, Click here + Websocket connection lost, Click here to reconnect.
diff --git a/ui/app/components/History.vue b/ui/app/components/History.vue index 668291cf..4b258a02 100644 --- a/ui/app/components/History.vue +++ b/ui/app/components/History.vue @@ -583,7 +583,7 @@ watch(showCompleted, async isShown => { }) onMounted(async () => { - if (showCompleted.value) { + if (showCompleted.value && !paginationInfo.value.isLoaded) { try { await stateStore.loadPaginated('history', 1, config.app.default_pagination, 'DESC', true) } catch (error) { diff --git a/ui/app/components/Simple.vue b/ui/app/components/Simple.vue index 8f64e778..11c65d04 100644 --- a/ui/app/components/Simple.vue +++ b/ui/app/components/Simple.vue @@ -7,8 +7,8 @@ - + @@ -273,7 +273,6 @@ const refreshQueue = async (): Promise => { } finally { isRefreshing.value = false } - } const paginationInfo = computed(() => stateStore.getPagination()) @@ -691,10 +690,12 @@ onMounted(async () => { window.history.replaceState({}, '', url.toString()) } - try { - await stateStore.loadPaginated('history', 1, DEFAULT_PAGE_SIZE, 'DESC') - } catch (error) { - console.error('Failed to load history on mount:', error) + if (!paginationInfo.value.isLoaded) { + try { + await stateStore.loadPaginated('history', 1, DEFAULT_PAGE_SIZE, 'DESC') + } catch (error) { + console.error('Failed to load history on mount:', error) + } } if (window?.location && '/' !== window.location.pathname) { @@ -702,7 +703,6 @@ onMounted(async () => { } }) -// Reload history when socket reconnects watch(() => socketStore.isConnected, async (connected) => { if (connected && !paginationInfo.value.isLoaded) { try { @@ -713,7 +713,6 @@ watch(() => socketStore.isConnected, async (connected) => { } }) -// Function to load more history items const loadMoreHistory = async (): Promise => { if (paginationInfo.value.isLoading || paginationInfo.value.page >= paginationInfo.value.total_pages) { return diff --git a/ui/app/layouts/default.vue b/ui/app/layouts/default.vue index 71b6635f..a7b482eb 100644 --- a/ui/app/layouts/default.vue +++ b/ui/app/layouts/default.vue @@ -1,6 +1,7 @@