-
Notifications
You must be signed in to change notification settings - Fork 471
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Increase the local sync's ready to flush seconds to 120 #1014
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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<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++; | ||
}); | ||
} | ||
}); | ||
} | ||
|
||
Comment on lines
+29
to
+44
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The timer is being initialized in the - _missSecondsInEstTimer = Timer.periodic(const Duration(seconds: 1), (t) {
- if (_missSecondsInEstTimerEnabled) {
- setState(() {
- _missSeconds++;
- });
- }
- });
+ // Move timer initialization to a separate method
+ void startTimer() {
+ _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<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) { | ||
Comment on lines
+55
to
+59
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The condition for setting |
||
_status = LocalSyncStatus.inProgress; | ||
} else { | ||
_status = LocalSyncStatus.disabled; | ||
|
@@ -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; | ||
Comment on lines
+75
to
+77
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The timer control logic has been simplified by introducing the - _missSecondsInEstTimerEnabled = true;
+ if (!_missSecondsInEstTimerEnabled) {
+ _missSecondsInEstTimerEnabled = true;
+ startTimer();
+ } - _missSecondsInEstTimerEnabled = false;
+ if (_missSecondsInEstTimerEnabled) {
+ _missSecondsInEstTimerEnabled = false;
+ cancelTimer();
+ } |
||
} | ||
|
||
// in progress | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Entelligence.AI
The change from displaying the sync progress as a floating-point number to an integer is a good one for readability. However, it might lead to less precision in the progress display. If the syncing process is slow, users might not see the progress update for a while because the percentage will only increase when it reaches the next whole number. Consider keeping the floating-point precision up to 1 or 2 decimal places.