From a724f94faed2c17f71286c1eb8c07ea44c75cf11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=85=B1=E5=A4=A9=E5=B0=8F=E7=A6=BD=E5=85=BD?= Date: Sat, 4 May 2024 16:06:35 +0800 Subject: [PATCH] Fix bug with file search MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复文件搜索时的相关bug --- changelog/v7.5.3+208.md | 5 +++++ .../search/mixin/search_page_logic_mixin.dart | 18 +++++++++++++----- pubspec.yaml | 2 +- 3 files changed, 19 insertions(+), 6 deletions(-) create mode 100644 changelog/v7.5.3+208.md diff --git a/changelog/v7.5.3+208.md b/changelog/v7.5.3+208.md new file mode 100644 index 00000000..f5678520 --- /dev/null +++ b/changelog/v7.5.3+208.md @@ -0,0 +1,5 @@ +- 修复文件搜索时的相关bug + +------------------------------------------------------------------------------------------ + +- Fix bug with file search \ No newline at end of file diff --git a/lib/src/pages/search/mixin/search_page_logic_mixin.dart b/lib/src/pages/search/mixin/search_page_logic_mixin.dart index 7fc0dbef..e10f8290 100644 --- a/lib/src/pages/search/mixin/search_page_logic_mixin.dart +++ b/lib/src/pages/search/mixin/search_page_logic_mixin.dart @@ -89,9 +89,14 @@ mixin SearchPageLogicMixin on BasePageLogic { Future handleFileSearch() async { FilePickerResult? result; try { - result = await FilePicker.platform.pickFiles(type: FileType.image); + result = await FilePicker.platform.pickFiles( + type: FileType.image, + allowCompression: false, + compressionQuality: 0, + ); } on Exception catch (e) { Log.error('Pick file failed', e); + return; } if (result == null) { @@ -114,7 +119,7 @@ mixin SearchPageLogicMixin on BasePageLogic { state.loadingState = LoadingState.loading; state.searchConfig.keyword = null; - update(); + updateSafely(); try { state.redirectUrl = await EHRequest.requestLookup( @@ -125,18 +130,21 @@ mixin SearchPageLogicMixin on BasePageLogic { } on DioException catch (e) { Log.error('fileSearchFailed'.tr, e.errorMsg); snack('fileSearchFailed'.tr, e.errorMsg ?? ''); + state.hasSearched = false; state.loadingState = LoadingState.idle; - update([loadingStateId]); + updateSafely(); return; } on EHSiteException catch (e) { Log.error('fileSearchFailed'.tr, e.message); snack('fileSearchFailed'.tr, e.message); + state.hasSearched = false; state.loadingState = LoadingState.idle; - update([loadingStateId]); + updateSafely(); return; } on CheckException catch (_) { + state.hasSearched = false; state.loadingState = LoadingState.idle; - update([loadingStateId]); + updateSafely(); rethrow; } diff --git a/pubspec.yaml b/pubspec.yaml index 39391285..ffee4e78 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,7 +2,7 @@ name: jhentai description: A flutter app for E-Hentai/EXHentai publish_to: 'none' -version: 7.5.3+207 +version: 7.5.3+208 environment: sdk: '>=3.0.0 <4.0.0'