From 1c945b9cac2582ee23ca4676b895e18083bd7d60 Mon Sep 17 00:00:00 2001 From: MythEclipse Date: Thu, 14 May 2026 04:12:33 +0700 Subject: [PATCH] fix: trigger backlog sync when text channel is selected - Call POST /api/backlog-sync when user selects a text channel - Backlog sync now runs automatically on channel selection - Fetches messages from last 24 hours for selected channel only - Prevents empty message list on first channel selection This resolves: - Empty message list when selecting channel - Backlog sync not being triggered - Messages not loading until manual refresh Co-Authored-By: Claude Opus 4.7 --- public/index.html | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/public/index.html b/public/index.html index 228fa0f..1498bb2 100644 --- a/public/index.html +++ b/public/index.html @@ -110,7 +110,15 @@ el.channelSelect.value = state.selectedVoiceChannel; el.channelFilter.value = state.selectedTextChannel; applyActiveTab(state.activeTab); - if (textChanged || state.activeTab === 'text') await fetchText().catch((error) => showError(error.message)); + if (textChanged || state.activeTab === 'text') { + if (state.selectedTextChannel && state.selectedGuild) { + await apiRequest('/api/backlog-sync', { + method: 'POST', + body: JSON.stringify({ guildId: state.selectedGuild, channelId: state.selectedTextChannel }), + }).catch((error) => logger.warn('Backlog sync failed:', error.message)); + } + await fetchText().catch((error) => showError(error.message)); + } await reconcileListenState(); await reconcileStreamingState(); state.applyingServerState = false;