fix auto sync chat delay not applying when toggled on mid-session

When showLatency was already tracking, toggling autoSyncChatDelay on
would wait up to 60s for the next tracker cycle instead of using the
cached latency value immediately.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Tommy Chow 2026-03-07 23:34:01 -08:00
parent 9cec89a67c
commit eb91146f63

View file

@ -315,6 +315,20 @@ abstract class VideoStoreBase with Store {
// Start tracker if either setting is now enabled
// The init() method is idempotent - won't double-start if already running
await _listenOnLatencyChanges();
// If autoSync was just enabled and we already have a cached latency
// value (e.g. from showLatency tracking), apply it immediately instead
// of waiting for the next tracker cycle (up to 60s).
if (autoSync && _latency != null) {
final numericPart = _latency!.replaceAll(
RegExp(r'[^0-9.]'),
'',
);
final latencyAsDouble = double.tryParse(numericPart);
if (latencyAsDouble != null) {
settingsStore.syncedChatDelay = latencyAsDouble;
}
}
} else {
// Stop tracker if both settings are now disabled
try {