mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-07-29 23:08:44 +10:00
Onstart sync progressbar: fix potential bug with spinner on interrupt synchronization
This commit is contained in:
@@ -3637,6 +3637,12 @@ class MeshCoreConnector extends ChangeNotifier {
|
|||||||
if (completed) {
|
if (completed) {
|
||||||
_hasLoadedChannels = true;
|
_hasLoadedChannels = true;
|
||||||
_previousChannelsCache.clear();
|
_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) {
|
if (isConnected) {
|
||||||
@@ -3644,6 +3650,9 @@ class MeshCoreConnector extends ChangeNotifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Keep cache on failure/disconnection for future attempts
|
// Keep cache on failure/disconnection for future attempts
|
||||||
|
if (!completed) {
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _startPostChannelInitialQueuedMessageSync() {
|
void _startPostChannelInitialQueuedMessageSync() {
|
||||||
|
|||||||
@@ -155,12 +155,13 @@ class _ChannelsScreenState extends State<ChannelsScreen>
|
|||||||
},
|
},
|
||||||
child: () {
|
child: () {
|
||||||
final channels = connector.channels;
|
final channels = connector.channels;
|
||||||
final waitingForInitialChannels =
|
|
||||||
!connector.hasLoadedChannels && !connector.isLoadingChannels;
|
|
||||||
final waitingForFirstChannel =
|
final waitingForFirstChannel =
|
||||||
connector.isLoadingChannels && channels.isEmpty;
|
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());
|
return const Center(child: CircularProgressIndicator());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user