From 2328848400b002e626363eea535c2b42f426504d Mon Sep 17 00:00:00 2001 From: HDDen <62592944+HDDen@users.noreply.github.com> Date: Tue, 26 May 2026 00:37:42 +0300 Subject: [PATCH] Onstart sync progressbar: fix potential bug with spinner on interrupt synchronization --- lib/connector/meshcore_connector.dart | 9 +++++++++ lib/screens/channels_screen.dart | 7 ++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/connector/meshcore_connector.dart b/lib/connector/meshcore_connector.dart index d1581e44..271ea069 100644 --- a/lib/connector/meshcore_connector.dart +++ b/lib/connector/meshcore_connector.dart @@ -3637,6 +3637,12 @@ class MeshCoreConnector extends ChangeNotifier { if (completed) { _hasLoadedChannels = true; _previousChannelsCache.clear(); + } else if (_channels.isEmpty && _previousChannelsCache.isNotEmpty) { + // A failed initial sync should not leave the UI empty/spinning forever. + // Restore the pre-sync list so cached channels remain usable. + _channels.addAll(_previousChannelsCache); + _applyChannelOrder(); + _recalculateCachedChannelsUnreadTotal(); } if (isConnected) { @@ -3644,6 +3650,9 @@ class MeshCoreConnector extends ChangeNotifier { } // Keep cache on failure/disconnection for future attempts + if (!completed) { + notifyListeners(); + } } void _startPostChannelInitialQueuedMessageSync() { diff --git a/lib/screens/channels_screen.dart b/lib/screens/channels_screen.dart index 1475bdef..40726021 100644 --- a/lib/screens/channels_screen.dart +++ b/lib/screens/channels_screen.dart @@ -155,12 +155,13 @@ class _ChannelsScreenState extends State }, child: () { final channels = connector.channels; - final waitingForInitialChannels = - !connector.hasLoadedChannels && !connector.isLoadingChannels; final waitingForFirstChannel = connector.isLoadingChannels && channels.isEmpty; - if (waitingForInitialChannels || waitingForFirstChannel) { + // Only block the list while the first channel is actively loading. + // If the initial sync aborts, show cached/partial channels instead + // of trapping the user behind an idle spinner. + if (waitingForFirstChannel) { return const Center(child: CircularProgressIndicator()); }