fix(search): let latest live queries supersede cancelled requests

This commit is contained in:
zarzet
2026-09-06 02:34:49 +07:00
parent d95d070565
commit 856139f908
4 changed files with 83 additions and 32 deletions
+5 -1
View File
@@ -611,6 +611,9 @@ class PlatformBridge {
}) {
for (final entry in _customSearchInFlight.entries.toList()) {
if (entry.key == exceptKey || entry.value.scopeKey != scopeKey) continue;
// A cancelled request must not be reused if the user types its query
// again before the native cancellation finishes.
_customSearchInFlight.remove(entry.key);
_cancelExtensionRequestUnawaited(entry.value.requestId);
}
}
@@ -1824,7 +1827,8 @@ class PlatformBridge {
'request_id': requestId,
});
final decoded = _decodeMapListResult(result, 'customSearchWithExtension');
if (generation == _lookupCacheGeneration) {
if (generation == _lookupCacheGeneration &&
_customSearchInFlight[cacheKey]?.requestId == requestId) {
_putMemoryCachedMapList(
_customSearchCache,
cacheKey,