fix platform exceptions
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
*/
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_mozilla_components/flutter_mozilla_components.dart';
|
||||
import 'package:nullability/nullability.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
@@ -105,11 +106,16 @@ class BookmarksSearch extends _$BookmarksSearch {
|
||||
|
||||
Future<void> search(String query, {int limit = 10}) async {
|
||||
if (query.isNotEmpty) {
|
||||
await _service.searchBookmarks(query, limit: limit).then((value) {
|
||||
if (!_streamController.isClosed) {
|
||||
_streamController.add(value.map((e) => e.guid).toSet());
|
||||
}
|
||||
});
|
||||
try {
|
||||
await _service.searchBookmarks(query, limit: limit).then((value) {
|
||||
if (!_streamController.isClosed) {
|
||||
_streamController.add(value.map((e) => e.guid).toSet());
|
||||
}
|
||||
});
|
||||
} on PlatformException catch (e) {
|
||||
if (e.code == 'OperationInterrupted') return;
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,12 +141,17 @@ class BookmarkSearchResults extends _$BookmarkSearchResults {
|
||||
return;
|
||||
}
|
||||
|
||||
final results = await _service.searchBookmarks(query, limit: limit);
|
||||
if (!ref.mounted) return;
|
||||
state = results
|
||||
.map(BookmarkItem.parseRecursive)
|
||||
.whereType<BookmarkEntry>()
|
||||
.toList();
|
||||
try {
|
||||
final results = await _service.searchBookmarks(query, limit: limit);
|
||||
if (!ref.mounted) return;
|
||||
state = results
|
||||
.map(BookmarkItem.parseRecursive)
|
||||
.whereType<BookmarkEntry>()
|
||||
.toList();
|
||||
} on PlatformException catch (e) {
|
||||
if (e.code == 'OperationInterrupted') return;
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -33,7 +33,7 @@ final class BookmarksSearchProvider
|
||||
BookmarksSearch create() => BookmarksSearch();
|
||||
}
|
||||
|
||||
String _$bookmarksSearchHash() => r'ac2ce51c4fd66c2c0e25bdf2475cf2fba57c9e0c';
|
||||
String _$bookmarksSearchHash() => r'41053cbc1014e0fdd04d9510bf15c9896a9f752d';
|
||||
|
||||
abstract class _$BookmarksSearch extends $StreamNotifier<Set<String>> {
|
||||
Stream<Set<String>> build();
|
||||
@@ -86,7 +86,7 @@ final class BookmarkSearchResultsProvider
|
||||
}
|
||||
|
||||
String _$bookmarkSearchResultsHash() =>
|
||||
r'44af94b2234c817b08b0bde2dc68f9ab8d2d0a9a';
|
||||
r'49ebd21a137bc09bbd67b692aacb2554b8364564';
|
||||
|
||||
abstract class _$BookmarkSearchResults extends $Notifier<List<BookmarkEntry>> {
|
||||
List<BookmarkEntry> build();
|
||||
|
||||
Reference in New Issue
Block a user