Wait-for-igc (#1311)

* feat: wait longer before calling igc

* fix: don't call showFirstMatch if running IT

---------

Co-authored-by: ggurdin <46800240+ggurdin@users.noreply.github.com>
Co-authored-by: ggurdin <ggurdin@gmail.com>
pull/1544/head
wcjord 11 months ago committed by GitHub
parent 6491042d59
commit 93b1f7e21d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -48,6 +48,8 @@ class Choreographer {
bool isFetching = false;
int _timesClicked = 0;
final int msBeforeIGCStart = 10000;
Timer? debounceTimer;
ChoreoRecord choreoRecord = ChoreoRecord.newRecord;
// last checked by IGC or translation
@ -77,10 +79,13 @@ class Choreographer {
void send(BuildContext context) {
debugPrint("can send message: $canSendMessage");
if (!canSendMessage) {
if (igc.igcTextData != null && igc.igcTextData!.matches.isNotEmpty) {
igc.showFirstMatch(context);
}
if (igc.igcTextData != null && igc.igcTextData!.matches.isNotEmpty) {
igc.showFirstMatch(context);
return;
} else if (isRunningIT) {
// If the user is in the middle of IT, don't send the message.
// If they've already clicked the send button once, this will
// not be true, so they can still send it if they want.
return;
}
@ -107,7 +112,11 @@ class Choreographer {
Future<void> _sendWithIGC(BuildContext context) async {
if (!canSendMessage) {
igc.showFirstMatch(context);
// It's possible that the reason user can't send message is because they're in the middle of IT. If this is the case,
// do nothing (there's no matches to show). The user can click the send button again to override this.
if (!isRunningIT) {
igc.showFirstMatch(context);
}
return;
}
@ -237,7 +246,7 @@ class Choreographer {
if (editTypeIsKeyboard) {
debounceTimer ??= Timer(
const Duration(milliseconds: 1500),
Duration(milliseconds: msBeforeIGCStart),
() => getLanguageHelp(),
);
} else {

@ -16,7 +16,7 @@ class FullTextTranslationRepo {
// start a timer to clear the cache
static void startCacheTimer() {
_cacheTimer = Timer.periodic(const Duration(minutes: 3), (timer) {
_cacheTimer = Timer.periodic(const Duration(minutes: 10), (timer) {
clearCache();
});
}

Loading…
Cancel
Save