Skip to content

Commit

Permalink
Increase the local sync's ready to flush seconds to 120
Browse files Browse the repository at this point in the history
  • Loading branch information
beastoin committed Oct 9, 2024
1 parent ac05dc9 commit 1e934b0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
2 changes: 1 addition & 1 deletion app/lib/pages/memories/sync_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class _SyncPageState extends State<SyncPage> {
),
memoryProvider.isSyncing
? Text(
'${memoryProvider.walsSyncedProgress}% synced',
'${(memoryProvider.walsSyncedProgress * 100).toInt()}% synced',
style: const TextStyle(color: Colors.white, fontSize: 16),
)
: const SizedBox.shrink(),
Expand Down
28 changes: 18 additions & 10 deletions app/lib/pages/memories/widgets/local_sync.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -27,8 +26,22 @@ enum LocalSyncStatus {
class _LocalSyncWidgetState extends State<LocalSyncWidget> {
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();
Expand All @@ -39,11 +52,11 @@ class _LocalSyncWidgetState extends State<LocalSyncWidget> {
Widget build(BuildContext context) {
return Consumer2<MemoryProvider, CaptureProvider>(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;
Expand All @@ -59,14 +72,9 @@ class _LocalSyncWidgetState extends State<LocalSyncWidget> {
// 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
Expand Down

0 comments on commit 1e934b0

Please sign in to comment.