From 1e934b0b71b2a444cbbc5a686ac88860064da94a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?th=E1=BB=8Bnh?= Date: Wed, 9 Oct 2024 19:22:22 +0700 Subject: [PATCH] Increase the local sync's ready to flush seconds to 120 --- app/lib/pages/memories/sync_page.dart | 2 +- .../pages/memories/widgets/local_sync.dart | 28 ++++++++++++------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/app/lib/pages/memories/sync_page.dart b/app/lib/pages/memories/sync_page.dart index f818299d5..c2453df55 100644 --- a/app/lib/pages/memories/sync_page.dart +++ b/app/lib/pages/memories/sync_page.dart @@ -76,7 +76,7 @@ class _SyncPageState extends State { ), memoryProvider.isSyncing ? Text( - '${memoryProvider.walsSyncedProgress}% synced', + '${(memoryProvider.walsSyncedProgress * 100).toInt()}% synced', style: const TextStyle(color: Colors.white, fontSize: 16), ) : const SizedBox.shrink(), diff --git a/app/lib/pages/memories/widgets/local_sync.dart b/app/lib/pages/memories/widgets/local_sync.dart index be651aca7..b43b6ba9e 100644 --- a/app/lib/pages/memories/widgets/local_sync.dart +++ b/app/lib/pages/memories/widgets/local_sync.dart @@ -5,7 +5,6 @@ import 'package:flutter/material.dart'; import 'package:friend_private/pages/memories/page.dart'; import 'package:friend_private/pages/memories/sync_page.dart'; import 'package:friend_private/providers/capture_provider.dart'; -import 'package:friend_private/providers/developer_mode_provider.dart'; import 'package:friend_private/providers/memory_provider.dart'; import 'package:friend_private/utils/other/string_utils.dart'; import 'package:friend_private/utils/other/temp.dart'; @@ -27,8 +26,22 @@ enum LocalSyncStatus { class _LocalSyncWidgetState extends State { LocalSyncStatus? _status; Timer? _missSecondsInEstTimer; + bool _missSecondsInEstTimerEnabled = false; int _missSeconds = 0; + @override + void initState() { + super.initState(); + + _missSecondsInEstTimer = Timer.periodic(const Duration(seconds: 1), (t) { + if (_missSecondsInEstTimerEnabled) { + setState(() { + _missSeconds++; + }); + } + }); + } + @override void dispose() { _missSecondsInEstTimer?.cancel(); @@ -39,11 +52,11 @@ class _LocalSyncWidgetState extends State { Widget build(BuildContext context) { return Consumer2(builder: (context, provider, captureProvider, child) { var previousStatus = _status; - if (provider.missingWalsInSeconds > 120) { + if (provider.missingWalsInSeconds >= 120) { _status = LocalSyncStatus.flush; } else if (!captureProvider.isWalSupported) { _status = LocalSyncStatus.disabled; - } else if (provider.missingWalsInSeconds > 0) { + } else if (!captureProvider.transcriptServiceReady && captureProvider.recordingDeviceServiceReady) { _status = LocalSyncStatus.inProgress; } else { _status = LocalSyncStatus.disabled; @@ -59,14 +72,9 @@ class _LocalSyncWidgetState extends State { // timer if ((_status == LocalSyncStatus.inProgress || _status == LocalSyncStatus.flush) && (!captureProvider.transcriptServiceReady && captureProvider.recordingDeviceServiceReady)) { - _missSecondsInEstTimer ??= Timer.periodic(const Duration(seconds: 1), (t) { - setState(() { - _missSeconds++; - }); - }); + _missSecondsInEstTimerEnabled = true; } else { - _missSecondsInEstTimer?.cancel(); - _missSecondsInEstTimer = null; + _missSecondsInEstTimerEnabled = false; } // in progress