Skip to content

Commit 0bf7593

Browse files
committed
Tweak: Preserve syncing button progress bar between pages
1 parent cd50dce commit 0bf7593

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/components/home/syncing_button.dart

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class SyncingButton extends StatefulWidget {
1919

2020
class _SyncingButtonState extends State<SyncingButton> {
2121
/// The number of files transferred since we started listening.
22-
int filesTransferred = 0;
22+
static int filesTransferred = 0;
2323

2424
late final StreamSubscription queueListener, transferListener;
2525

@@ -43,6 +43,7 @@ class _SyncingButtonState extends State<SyncingButton> {
4343
}
4444

4545
void _onUsernameChanged() {
46+
filesTransferred = 0;
4647
if (mounted) setState(() {});
4748
}
4849

@@ -51,11 +52,15 @@ class _SyncingButtonState extends State<SyncingButton> {
5152
double? getPercentage() {
5253
if (syncer.downloader.isRefreshing) {
5354
// If still refreshing, show an indeterminate progress indicator.
55+
filesTransferred = 0;
5456
return null;
5557
}
5658

5759
final numPending = syncer.downloader.numPending;
58-
if (numPending == 0) return 1;
60+
if (numPending == 0) {
61+
filesTransferred = 0;
62+
return 1;
63+
}
5964

6065
return (0.2 + filesTransferred) / (0.2 + filesTransferred + numPending);
6166
}

0 commit comments

Comments
 (0)