From 86e4cbcc2926b4a191e71df6d9874ae52bf79e7b Mon Sep 17 00:00:00 2001 From: kidozh <11661760+kidozh@users.noreply.github.com> Date: Fri, 6 Sep 2024 00:58:55 +0100 Subject: [PATCH] add update --- ios/Podfile | 50 - ios/Runner.xcodeproj/project.pbxproj | 6 +- lib/JsonResult/CheckPostResult.dart | 4 +- lib/JsonResult/CheckPostResult.g.dart | 10 +- lib/JsonResult/SupportDiscuzListResult.dart | 5 - lib/client/CheveretoApiClient.dart | 1 + lib/client/CheveretoApiClient.g.dart | 37 +- lib/client/MobileApiClient.g.dart | 1247 +++++++++++------- lib/client/PushServiceClient.dart | 1 + lib/client/PushServiceClient.g.dart | 173 ++- lib/client/UtilityServiceApiClient.dart | 3 +- lib/client/UtilityServiceApiClient.g.dart | 16 +- lib/entity/DiscuzError.dart | 3 +- lib/generated/intl/messages_en.dart | 14 +- lib/generated/intl/messages_zh_CN.dart | 12 +- lib/generated/l10n.dart | 44 +- lib/l10n/intl_en.arb | 8 +- lib/l10n/intl_zh_CN.arb | 10 +- lib/page/AddDiscuzPage.dart | 22 +- lib/page/ChooseDynamicSchemeVariantPage.dart | 1 - lib/page/DrawerPage.dart | 1 - lib/page/SettingPage.dart | 1 - lib/screen/DashboardScreen.dart | 1 - lib/screen/ExtraFuncInThreadScreen.dart | 33 + lib/screen/PrivateMessagePortalScreen.dart | 8 +- lib/widget/AppBannerAdWidget.dart | 1 - lib/widget/DiscuzHtmlWidget.dart | 16 +- lib/widget/ErrorCard.dart | 11 + lib/widget/PostWidget.dart | 1 - lib/widget/PrivateMessagePortalWidget.dart | 5 - 30 files changed, 1066 insertions(+), 679 deletions(-) delete mode 100644 ios/Podfile diff --git a/ios/Podfile b/ios/Podfile deleted file mode 100644 index 7e136118..00000000 --- a/ios/Podfile +++ /dev/null @@ -1,50 +0,0 @@ -# Uncomment this line to define a global platform for your project -platform :ios, '14.0' - -# CocoaPods analytics sends network stats synchronously affecting flutter build latency. -ENV['COCOAPODS_DISABLE_STATS'] = 'true' - -$FirebaseAnalyticsWithoutAdIdSupport = true - -project 'Runner', { - 'Debug' => :debug, - 'Profile' => :release, - 'Release' => :release, -} - -def flutter_root - generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) - unless File.exist?(generated_xcode_build_settings_path) - raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" - end - - File.foreach(generated_xcode_build_settings_path) do |line| - matches = line.match(/FLUTTER_ROOT\=(.*)/) - return matches[1].strip if matches - end - raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" -end - -require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) - -flutter_ios_podfile_setup - -target 'Runner' do - use_frameworks! - use_modular_headers! - - flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) -end - - - -post_install do |installer| - installer.pods_project.targets.each do |target| - flutter_additional_ios_build_settings(target) - end -end - -# target 'ImageNotification' do -# use_frameworks! -# pod 'Firebase/Messaging' -# end diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index dcd02e0e..5eaeda25 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -399,7 +399,7 @@ ENABLE_BITCODE = NO; ENABLE_USER_SCRIPT_SANDBOXING = NO; INFOPLIST_FILE = Runner/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 15.0; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -543,7 +543,7 @@ ENABLE_BITCODE = NO; ENABLE_USER_SCRIPT_SANDBOXING = NO; INFOPLIST_FILE = Runner/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 15.0; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -573,7 +573,7 @@ ENABLE_BITCODE = NO; ENABLE_USER_SCRIPT_SANDBOXING = NO; INFOPLIST_FILE = Runner/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 15.0; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", diff --git a/lib/JsonResult/CheckPostResult.dart b/lib/JsonResult/CheckPostResult.dart index 680838ad..6a6d7172 100644 --- a/lib/JsonResult/CheckPostResult.dart +++ b/lib/JsonResult/CheckPostResult.dart @@ -53,6 +53,7 @@ class AllowPerm{ @JsonSerializable(ignoreUnannotated: true) class AllowUpload{ + @StringToIntConverter() int jpg = 0, jpeg = 0, gif = 0, png = 0, mp3 = 0, txt = 0, zip = -1, rar = -1, pdf = -1; AllowUpload(); @@ -60,8 +61,9 @@ class AllowUpload{ factory AllowUpload.fromJson(Map json) => _$AllowUploadFromJson(json); } -@JsonSerializable(ignoreUnannotated: true) +@JsonSerializable() class AttachRemain{ + @StringToIntConverter() int size = 0, count = 0; AttachRemain(); diff --git a/lib/JsonResult/CheckPostResult.g.dart b/lib/JsonResult/CheckPostResult.g.dart index 3c377676..e8ce9aa5 100644 --- a/lib/JsonResult/CheckPostResult.g.dart +++ b/lib/JsonResult/CheckPostResult.g.dart @@ -87,8 +87,12 @@ AllowUpload _$AllowUploadFromJson(Map json) => AllowUpload(); Map _$AllowUploadToJson(AllowUpload instance) => {}; -AttachRemain _$AttachRemainFromJson(Map json) => - AttachRemain(); +AttachRemain _$AttachRemainFromJson(Map json) => AttachRemain() + ..size = const StringToIntConverter().fromJson(json['size'] as String?) + ..count = const StringToIntConverter().fromJson(json['count'] as String?); Map _$AttachRemainToJson(AttachRemain instance) => - {}; + { + 'size': const StringToIntConverter().toJson(instance.size), + 'count': const StringToIntConverter().toJson(instance.count), + }; diff --git a/lib/JsonResult/SupportDiscuzListResult.dart b/lib/JsonResult/SupportDiscuzListResult.dart index e22f70a6..8ce7351e 100644 --- a/lib/JsonResult/SupportDiscuzListResult.dart +++ b/lib/JsonResult/SupportDiscuzListResult.dart @@ -1,11 +1,6 @@ -import 'package:discuz_flutter/JsonResult/BaseVariableResult.dart'; -import 'package:discuz_flutter/entity/Smiley.dart'; import 'package:json_annotation/json_annotation.dart'; -import 'package:discuz_flutter/converter/StringToIntConverter.dart'; -import 'BaseResult.dart'; -import 'ErrorResult.dart'; part 'SupportDiscuzListResult.g.dart'; diff --git a/lib/client/CheveretoApiClient.dart b/lib/client/CheveretoApiClient.dart index 1c774fd4..f2449546 100644 --- a/lib/client/CheveretoApiClient.dart +++ b/lib/client/CheveretoApiClient.dart @@ -1,5 +1,6 @@ import 'package:dio/dio.dart' hide Headers; import 'package:discuz_flutter/JsonResult/ChevertoUploadResult.dart'; +import 'package:retrofit/error_logger.dart'; import 'package:retrofit/http.dart'; part 'CheveretoApiClient.g.dart'; diff --git a/lib/client/CheveretoApiClient.g.dart b/lib/client/CheveretoApiClient.g.dart index 411ab62b..63370960 100644 --- a/lib/client/CheveretoApiClient.g.dart +++ b/lib/client/CheveretoApiClient.g.dart @@ -12,6 +12,7 @@ class _CheveretoApiClient implements CheveretoApiClient { _CheveretoApiClient( this._dio, { this.baseUrl, + this.errorLogger, }) { baseUrl ??= 'https://sm.ms'; } @@ -20,6 +21,8 @@ class _CheveretoApiClient implements CheveretoApiClient { String? baseUrl; + final ParseErrorLogger? errorLogger; + @override Future uploadImageToChevereto( String apiToken, @@ -30,25 +33,31 @@ class _CheveretoApiClient implements CheveretoApiClient { final _headers = {r'X-API-Key': apiToken}; _headers.removeWhere((k, v) => v == null); final _data = {'source': base64String}; - final _result = await _dio.fetch>( - _setStreamType(Options( + final _options = _setStreamType(Options( method: 'POST', headers: _headers, extra: _extra, contentType: 'application/x-www-form-urlencoded', ) - .compose( - _dio.options, - '/api/1/upload/', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - final _value = ChevertoUploadResult.fromJson(_result.data!); + .compose( + _dio.options, + '/api/1/upload/', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late ChevertoUploadResult _value; + try { + _value = ChevertoUploadResult.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } diff --git a/lib/client/MobileApiClient.g.dart b/lib/client/MobileApiClient.g.dart index b46ca085..7457dd9b 100644 --- a/lib/client/MobileApiClient.g.dart +++ b/lib/client/MobileApiClient.g.dart @@ -12,6 +12,7 @@ class _MobileApiClient implements MobileApiClient { _MobileApiClient( this._dio, { this.baseUrl, + this.errorLogger, }) { baseUrl ??= 'https://keylol.com/'; } @@ -20,6 +21,8 @@ class _MobileApiClient implements MobileApiClient { String? baseUrl; + final ParseErrorLogger? errorLogger; + @override Future getCheckResult() async { final _extra = {}; @@ -27,25 +30,31 @@ class _MobileApiClient implements MobileApiClient { final _headers = {r'Content-Type': 'application/json'}; _headers.removeWhere((k, v) => v == null); const Map? _data = null; - final _result = await _dio - .fetch>(_setStreamType(Options( + final _options = _setStreamType(Options( method: 'GET', headers: _headers, extra: _extra, contentType: 'application/json', ) - .compose( - _dio.options, - '/api/mobile/index.php?version=4&module=check', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - final _value = CheckResult.fromJson(_result.data!); + .compose( + _dio.options, + '/api/mobile/index.php?version=4&module=check', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late CheckResult _value; + try { + _value = CheckResult.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } @@ -56,7 +65,7 @@ class _MobileApiClient implements MobileApiClient { final _headers = {r'Content-Type': 'application/json'}; _headers.removeWhere((k, v) => v == null); const Map? _data = null; - final _result = await _dio.fetch(_setStreamType(Options( + final _options = _setStreamType(Options( method: 'GET', headers: _headers, extra: _extra, @@ -72,8 +81,15 @@ class _MobileApiClient implements MobileApiClient { baseUrl: _combineBaseUrls( _dio.options.baseUrl, baseUrl, - )))); - final _value = _result.data!; + ))); + final _result = await _dio.fetch(_options); + late String _value; + try { + _value = _result.data!; + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } @@ -95,25 +111,31 @@ class _MobileApiClient implements MobileApiClient { 'seccodemodid': captchaType, 'seccodeverify': verification, }; - final _result = await _dio - .fetch>(_setStreamType(Options( + final _options = _setStreamType(Options( method: 'POST', headers: _headers, extra: _extra, contentType: 'application/x-www-form-urlencoded', ) - .compose( - _dio.options, - '/api/mobile/index.php?version=4&module=login&mod=logging&action=login&loginfield=username&loginsubmit=yes&cookietime=2592000', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - final _value = LoginResult.fromJson(_result.data!); + .compose( + _dio.options, + '/api/mobile/index.php?version=4&module=login&mod=logging&action=login&loginfield=username&loginsubmit=yes&cookietime=2592000', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late LoginResult _value; + try { + _value = LoginResult.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } @@ -135,7 +157,7 @@ class _MobileApiClient implements MobileApiClient { 'seccodemodid': captchaType, 'seccodeverify': verification, }; - final _result = await _dio.fetch(_setStreamType(Options( + final _options = _setStreamType(Options( method: 'POST', headers: _headers, extra: _extra, @@ -151,8 +173,15 @@ class _MobileApiClient implements MobileApiClient { baseUrl: _combineBaseUrls( _dio.options.baseUrl, baseUrl, - )))); - final _value = _result.data!; + ))); + final _result = await _dio.fetch(_options); + late String _value; + try { + _value = _result.data!; + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } @@ -162,24 +191,30 @@ class _MobileApiClient implements MobileApiClient { final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _result = await _dio - .fetch>(_setStreamType(Options( + final _options = _setStreamType(Options( method: 'GET', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/api/mobile/index.php?version=4&module=forumindex', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - final _value = DiscuzIndexResult.fromJson(_result.data!); + .compose( + _dio.options, + '/api/mobile/index.php?version=4&module=forumindex', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late DiscuzIndexResult _value; + try { + _value = DiscuzIndexResult.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } @@ -189,7 +224,7 @@ class _MobileApiClient implements MobileApiClient { final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _result = await _dio.fetch(_setStreamType(Options( + final _options = _setStreamType(Options( method: 'GET', headers: _headers, extra: _extra, @@ -204,8 +239,15 @@ class _MobileApiClient implements MobileApiClient { baseUrl: _combineBaseUrls( _dio.options.baseUrl, baseUrl, - )))); - final _value = _result.data!; + ))); + final _result = await _dio.fetch(_options); + late String _value; + try { + _value = _result.data!; + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } @@ -223,24 +265,30 @@ class _MobileApiClient implements MobileApiClient { queryParameters.addAll(queries); final _headers = {}; const Map? _data = null; - final _result = await _dio - .fetch>(_setStreamType(Options( + final _options = _setStreamType(Options( method: 'GET', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/api/mobile/index.php?version=4&module=forumdisplay', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - final _value = DisplayForumResult.fromJson(_result.data!); + .compose( + _dio.options, + '/api/mobile/index.php?version=4&module=forumdisplay', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late DisplayForumResult _value; + try { + _value = DisplayForumResult.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } @@ -258,7 +306,7 @@ class _MobileApiClient implements MobileApiClient { queryParameters.addAll(queries); final _headers = {}; const Map? _data = null; - final _result = await _dio.fetch(_setStreamType(Options( + final _options = _setStreamType(Options( method: 'GET', headers: _headers, extra: _extra, @@ -273,8 +321,15 @@ class _MobileApiClient implements MobileApiClient { baseUrl: _combineBaseUrls( _dio.options.baseUrl, baseUrl, - )))); - final _value = _result.data!; + ))); + final _result = await _dio.fetch(_options); + late String _value; + try { + _value = _result.data!; + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } @@ -292,24 +347,30 @@ class _MobileApiClient implements MobileApiClient { queryParameters.addAll(queries); final _headers = {}; const Map? _data = null; - final _result = await _dio - .fetch>(_setStreamType(Options( + final _options = _setStreamType(Options( method: 'GET', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/api/mobile/index.php?version=4&module=viewthread&ppp=15', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - final _value = ViewThreadResult.fromJson(_result.data!); + .compose( + _dio.options, + '/api/mobile/index.php?version=4&module=viewthread&ppp=15', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late ViewThreadResult _value; + try { + _value = ViewThreadResult.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } @@ -327,7 +388,7 @@ class _MobileApiClient implements MobileApiClient { queryParameters.addAll(queries); final _headers = {}; const Map? _data = null; - final _result = await _dio.fetch(_setStreamType(Options( + final _options = _setStreamType(Options( method: 'GET', headers: _headers, extra: _extra, @@ -342,8 +403,15 @@ class _MobileApiClient implements MobileApiClient { baseUrl: _combineBaseUrls( _dio.options.baseUrl, baseUrl, - )))); - final _value = _result.data!; + ))); + final _result = await _dio.fetch(_options); + late String _value; + try { + _value = _result.data!; + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } @@ -371,7 +439,7 @@ class _MobileApiClient implements MobileApiClient { 'seccodemodid': captchaType, 'seccodeverify': verification, }; - final _result = await _dio.fetch(_setStreamType(Options( + final _options = _setStreamType(Options( method: 'POST', headers: _headers, extra: _extra, @@ -387,8 +455,15 @@ class _MobileApiClient implements MobileApiClient { baseUrl: _combineBaseUrls( _dio.options.baseUrl, baseUrl, - )))); - final _value = _result.data!; + ))); + final _result = await _dio.fetch(_options); + late String _value; + try { + _value = _result.data!; + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } @@ -423,25 +498,31 @@ class _MobileApiClient implements MobileApiClient { 'seccodeverify': verification, }; _data.removeWhere((k, v) => v == null); - final _result = await _dio - .fetch>(_setStreamType(Options( + final _options = _setStreamType(Options( method: 'POST', headers: _headers, extra: _extra, contentType: 'application/x-www-form-urlencoded', ) - .compose( - _dio.options, - '/api/mobile/index.php?version=4&module=sendreply&action=reply&replysubmit=yes&usesig=1&seccodemodid=forum::viewthread', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - final _value = ApiResult.fromJson(_result.data!); + .compose( + _dio.options, + '/api/mobile/index.php?version=4&module=sendreply&action=reply&replysubmit=yes&usesig=1&seccodemodid=forum::viewthread', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late ApiResult _value; + try { + _value = ApiResult.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } @@ -451,7 +532,7 @@ class _MobileApiClient implements MobileApiClient { final queryParameters = {r'page': page}; final _headers = {}; const Map? _data = null; - final _result = await _dio.fetch(_setStreamType(Options( + final _options = _setStreamType(Options( method: 'GET', headers: _headers, extra: _extra, @@ -466,8 +547,15 @@ class _MobileApiClient implements MobileApiClient { baseUrl: _combineBaseUrls( _dio.options.baseUrl, baseUrl, - )))); - final _value = _result.data!; + ))); + final _result = await _dio.fetch(_options); + late String _value; + try { + _value = _result.data!; + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } @@ -477,24 +565,30 @@ class _MobileApiClient implements MobileApiClient { final queryParameters = {r'page': page}; final _headers = {}; const Map? _data = null; - final _result = await _dio.fetch>( - _setStreamType(Options( + final _options = _setStreamType(Options( method: 'GET', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/api/mobile/index.php?version=4&module=mynotelist', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - final _value = UserDiscuzNotificationResult.fromJson(_result.data!); + .compose( + _dio.options, + '/api/mobile/index.php?version=4&module=mynotelist', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late UserDiscuzNotificationResult _value; + try { + _value = UserDiscuzNotificationResult.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } @@ -504,7 +598,7 @@ class _MobileApiClient implements MobileApiClient { final queryParameters = {r'page': page}; final _headers = {}; const Map? _data = null; - final _result = await _dio.fetch(_setStreamType(Options( + final _options = _setStreamType(Options( method: 'GET', headers: _headers, extra: _extra, @@ -519,8 +613,15 @@ class _MobileApiClient implements MobileApiClient { baseUrl: _combineBaseUrls( _dio.options.baseUrl, baseUrl, - )))); - final _value = _result.data!; + ))); + final _result = await _dio.fetch(_options); + late String _value; + try { + _value = _result.data!; + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } @@ -530,24 +631,30 @@ class _MobileApiClient implements MobileApiClient { final queryParameters = {r'page': page}; final _headers = {}; const Map? _data = null; - final _result = await _dio - .fetch>(_setStreamType(Options( + final _options = _setStreamType(Options( method: 'GET', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/api/mobile/index.php?version=4&module=hotthread', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - final _value = HotThreadResult.fromJson(_result.data!); + .compose( + _dio.options, + '/api/mobile/index.php?version=4&module=hotthread', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late HotThreadResult _value; + try { + _value = HotThreadResult.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } @@ -557,24 +664,30 @@ class _MobileApiClient implements MobileApiClient { final queryParameters = {r'type': type}; final _headers = {}; const Map? _data = null; - final _result = await _dio - .fetch>(_setStreamType(Options( + final _options = _setStreamType(Options( method: 'GET', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/api/mobile/index.php?version=4&module=secure', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - final _value = CaptchaResult.fromJson(_result.data!); + .compose( + _dio.options, + '/api/mobile/index.php?version=4&module=secure', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late CaptchaResult _value; + try { + _value = CaptchaResult.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } @@ -595,25 +708,31 @@ class _MobileApiClient implements MobileApiClient { 'formhash': formHash, 'pollanswers[]': checkedOptionId, }; - final _result = await _dio - .fetch>(_setStreamType(Options( + final _options = _setStreamType(Options( method: 'POST', headers: _headers, extra: _extra, contentType: 'application/x-www-form-urlencoded', ) - .compose( - _dio.options, - '/api/mobile/index.php?version=4&module=pollvote&pollsubmit=yes&action=votepoll', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - final _value = ApiResult.fromJson(_result.data!); + .compose( + _dio.options, + '/api/mobile/index.php?version=4&module=pollvote&pollsubmit=yes&action=votepoll', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late ApiResult _value; + try { + _value = ApiResult.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } @@ -634,7 +753,7 @@ class _MobileApiClient implements MobileApiClient { 'formhash': formHash, 'pollanswers[]': checkedOptionId, }; - final _result = await _dio.fetch(_setStreamType(Options( + final _options = _setStreamType(Options( method: 'POST', headers: _headers, extra: _extra, @@ -650,8 +769,15 @@ class _MobileApiClient implements MobileApiClient { baseUrl: _combineBaseUrls( _dio.options.baseUrl, baseUrl, - )))); - final _value = _result.data!; + ))); + final _result = await _dio.fetch(_options); + late String _value; + try { + _value = _result.data!; + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } @@ -661,24 +787,30 @@ class _MobileApiClient implements MobileApiClient { final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _result = await _dio - .fetch>(_setStreamType(Options( + final _options = _setStreamType(Options( method: 'GET', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/api/mobile/index.php?version=4&module=login', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - final _value = CheckLoginResult.fromJson(_result.data!); + .compose( + _dio.options, + '/api/mobile/index.php?version=4&module=login', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late CheckLoginResult _value; + try { + _value = CheckLoginResult.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } @@ -688,24 +820,30 @@ class _MobileApiClient implements MobileApiClient { final queryParameters = {r'uid': uid}; final _headers = {}; const Map? _data = null; - final _result = await _dio - .fetch>(_setStreamType(Options( + final _options = _setStreamType(Options( method: 'GET', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/api/mobile/index.php?version=4&module=profile', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - final _value = UserProfileResult.fromJson(_result.data!); + .compose( + _dio.options, + '/api/mobile/index.php?version=4&module=profile', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late UserProfileResult _value; + try { + _value = UserProfileResult.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } @@ -715,7 +853,7 @@ class _MobileApiClient implements MobileApiClient { final queryParameters = {r'uid': uid}; final _headers = {}; const Map? _data = null; - final _result = await _dio.fetch(_setStreamType(Options( + final _options = _setStreamType(Options( method: 'GET', headers: _headers, extra: _extra, @@ -730,8 +868,15 @@ class _MobileApiClient implements MobileApiClient { baseUrl: _combineBaseUrls( _dio.options.baseUrl, baseUrl, - )))); - final _value = _result.data!; + ))); + final _result = await _dio.fetch(_options); + late String _value; + try { + _value = _result.data!; + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } @@ -741,24 +886,30 @@ class _MobileApiClient implements MobileApiClient { final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _result = await _dio - .fetch>(_setStreamType(Options( + final _options = _setStreamType(Options( method: 'GET', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/api/mobile/index.php?version=4&module=smiley', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - final _value = SmileyResult.fromJson(_result.data!); + .compose( + _dio.options, + '/api/mobile/index.php?version=4&module=smiley', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late SmileyResult _value; + try { + _value = SmileyResult.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } @@ -769,24 +920,30 @@ class _MobileApiClient implements MobileApiClient { final queryParameters = {r'page': page}; final _headers = {}; const Map? _data = null; - final _result = await _dio.fetch>( - _setStreamType(Options( + final _options = _setStreamType(Options( method: 'GET', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/api/mobile/index.php?version=4&module=mypm', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - final _value = PrivateMessagePortalResult.fromJson(_result.data!); + .compose( + _dio.options, + '/api/mobile/index.php?version=4&module=mypm', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late PrivateMessagePortalResult _value; + try { + _value = PrivateMessagePortalResult.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } @@ -802,24 +959,30 @@ class _MobileApiClient implements MobileApiClient { }; final _headers = {}; const Map? _data = null; - final _result = await _dio.fetch>( - _setStreamType(Options( + final _options = _setStreamType(Options( method: 'GET', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/api/mobile/index.php?version=4&module=mypm&subop=view', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - final _value = PrivateMessageDetailResult.fromJson(_result.data!); + .compose( + _dio.options, + '/api/mobile/index.php?version=4&module=mypm&subop=view', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late PrivateMessageDetailResult _value; + try { + _value = PrivateMessageDetailResult.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } @@ -837,25 +1000,31 @@ class _MobileApiClient implements MobileApiClient { 'message': message, 'touid': toUid, }; - final _result = await _dio - .fetch>(_setStreamType(Options( + final _options = _setStreamType(Options( method: 'POST', headers: _headers, extra: _extra, contentType: 'application/x-www-form-urlencoded', ) - .compose( - _dio.options, - '/api/mobile/index.php?version=4&ac=pm&op=send&daterange=0&module=sendpm&pmsubmit=yes', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - final _value = ApiResult.fromJson(_result.data!); + .compose( + _dio.options, + '/api/mobile/index.php?version=4&ac=pm&op=send&daterange=0&module=sendpm&pmsubmit=yes', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late ApiResult _value; + try { + _value = ApiResult.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } @@ -865,24 +1034,30 @@ class _MobileApiClient implements MobileApiClient { final queryParameters = {r'page': page}; final _headers = {}; const Map? _data = null; - final _result = await _dio.fetch>( - _setStreamType(Options( + final _options = _setStreamType(Options( method: 'GET', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/api/mobile/index.php?version=4&module=publicpm', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - final _value = PublicMessagePortalResult.fromJson(_result.data!); + .compose( + _dio.options, + '/api/mobile/index.php?version=4&module=publicpm', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late PublicMessagePortalResult _value; + try { + _value = PublicMessagePortalResult.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } @@ -892,24 +1067,30 @@ class _MobileApiClient implements MobileApiClient { final queryParameters = {r'page': page}; final _headers = {}; const Map? _data = null; - final _result = await _dio.fetch>( - _setStreamType(Options( + final _options = _setStreamType(Options( method: 'GET', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/api/mobile/index.php?version=4&module=myfavthread', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - final _value = FavoriteThreadResult.fromJson(_result.data!); + .compose( + _dio.options, + '/api/mobile/index.php?version=4&module=myfavthread', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late FavoriteThreadResult _value; + try { + _value = FavoriteThreadResult.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } @@ -938,7 +1119,7 @@ class _MobileApiClient implements MobileApiClient { filename: file.path.split(Platform.pathSeparator).last, ), )); - final _result = await _dio.fetch(_setStreamType(Options( + final _options = _setStreamType(Options( method: 'POST', headers: _headers, extra: _extra, @@ -954,8 +1135,15 @@ class _MobileApiClient implements MobileApiClient { baseUrl: _combineBaseUrls( _dio.options.baseUrl, baseUrl, - )))); - final _value = _result.data!; + ))); + final _result = await _dio.fetch(_options); + late String _value; + try { + _value = _result.data!; + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } @@ -972,24 +1160,30 @@ class _MobileApiClient implements MobileApiClient { queryParameters.removeWhere((k, v) => v == null); final _headers = {}; const Map? _data = null; - final _result = await _dio - .fetch>(_setStreamType(Options( + final _options = _setStreamType(Options( method: 'GET', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/api/mobile/index.php?version=4&module=checkpost', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - final _value = CheckPostResult.fromJson(_result.data!); + .compose( + _dio.options, + '/api/mobile/index.php?version=4&module=checkpost', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late CheckPostResult _value; + try { + _value = CheckPostResult.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } @@ -1011,7 +1205,7 @@ class _MobileApiClient implements MobileApiClient { 'rtype': rtype, 'rid': rid, }; - final _result = await _dio.fetch(_setStreamType(Options( + final _options = _setStreamType(Options( method: 'POST', headers: _headers, extra: _extra, @@ -1027,8 +1221,15 @@ class _MobileApiClient implements MobileApiClient { baseUrl: _combineBaseUrls( _dio.options.baseUrl, baseUrl, - )))); - final _value = _result.data!; + ))); + final _result = await _dio.fetch(_options); + late String _value; + try { + _value = _result.data!; + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } @@ -1044,25 +1245,31 @@ class _MobileApiClient implements MobileApiClient { 'formhash': formhash, 'id': tid, }; - final _result = await _dio - .fetch>(_setStreamType(Options( + final _options = _setStreamType(Options( method: 'POST', headers: _headers, extra: _extra, contentType: 'application/x-www-form-urlencoded', ) - .compose( - _dio.options, - '/api/mobile/index.php?version=4&module=favthread&type=thread&ac=favorite&favoritesubmit=true', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - final _value = ApiResult.fromJson(_result.data!); + .compose( + _dio.options, + '/api/mobile/index.php?version=4&module=favthread&type=thread&ac=favorite&favoritesubmit=true', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late ApiResult _value; + try { + _value = ApiResult.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } @@ -1078,25 +1285,31 @@ class _MobileApiClient implements MobileApiClient { 'formhash': formhash, 'favid': favid, }; - final _result = await _dio - .fetch>(_setStreamType(Options( + final _options = _setStreamType(Options( method: 'POST', headers: _headers, extra: _extra, contentType: 'application/x-www-form-urlencoded', ) - .compose( - _dio.options, - '/api/mobile/index.php?version=4&module=favthread&type=thread&ac=favorite&deletesubmit=true&op=delete', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - final _value = ApiResult.fromJson(_result.data!); + .compose( + _dio.options, + '/api/mobile/index.php?version=4&module=favthread&type=thread&ac=favorite&deletesubmit=true&op=delete', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late ApiResult _value; + try { + _value = ApiResult.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } @@ -1106,24 +1319,30 @@ class _MobileApiClient implements MobileApiClient { final queryParameters = {r'page': page}; final _headers = {}; const Map? _data = null; - final _result = await _dio.fetch>( - _setStreamType(Options( + final _options = _setStreamType(Options( method: 'GET', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/api/mobile/index.php?version=4&module=myfavforum', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - final _value = FavoriteForumResult.fromJson(_result.data!); + .compose( + _dio.options, + '/api/mobile/index.php?version=4&module=myfavforum', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late FavoriteForumResult _value; + try { + _value = FavoriteForumResult.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } @@ -1139,25 +1358,31 @@ class _MobileApiClient implements MobileApiClient { 'formhash': formhash, 'id': fid, }; - final _result = await _dio - .fetch>(_setStreamType(Options( + final _options = _setStreamType(Options( method: 'POST', headers: _headers, extra: _extra, contentType: 'application/x-www-form-urlencoded', ) - .compose( - _dio.options, - '/api/mobile/index.php?version=4&module=favforum&type=thread&ac=favorite&favoritesubmit=true', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - final _value = ApiResult.fromJson(_result.data!); + .compose( + _dio.options, + '/api/mobile/index.php?version=4&module=favforum&type=thread&ac=favorite&favoritesubmit=true', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late ApiResult _value; + try { + _value = ApiResult.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } @@ -1173,25 +1398,31 @@ class _MobileApiClient implements MobileApiClient { 'formhash': formhash, 'favid': favid, }; - final _result = await _dio - .fetch>(_setStreamType(Options( + final _options = _setStreamType(Options( method: 'POST', headers: _headers, extra: _extra, contentType: 'application/x-www-form-urlencoded', ) - .compose( - _dio.options, - '/api/mobile/index.php?version=4&module=favforum&type=thread&ac=favorite&deletesubmit=true&op=delete', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - final _value = ApiResult.fromJson(_result.data!); + .compose( + _dio.options, + '/api/mobile/index.php?version=4&module=favforum&type=thread&ac=favorite&deletesubmit=true&op=delete', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late ApiResult _value; + try { + _value = ApiResult.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } @@ -1207,24 +1438,30 @@ class _MobileApiClient implements MobileApiClient { }; final _headers = {}; const Map? _data = null; - final _result = await _dio - .fetch>(_setStreamType(Options( + final _options = _setStreamType(Options( method: 'GET', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/api/mobile/index.php?version=4&module=newthreads&limit=20', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - final _value = NewThreadResult.fromJson(_result.data!); + .compose( + _dio.options, + '/api/mobile/index.php?version=4&module=newthreads&limit=20', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late NewThreadResult _value; + try { + _value = NewThreadResult.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } @@ -1234,24 +1471,30 @@ class _MobileApiClient implements MobileApiClient { final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _result = await _dio.fetch>( - _setStreamType(Options( + final _options = _setStreamType(Options( method: 'GET', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/plugin.php?id=dhpush:token', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - final _value = PushTokenListResult.fromJson(_result.data!); + .compose( + _dio.options, + '/plugin.php?id=dhpush:token', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late PushTokenListResult _value; + try { + _value = PushTokenListResult.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } @@ -1273,25 +1516,31 @@ class _MobileApiClient implements MobileApiClient { 'packageId': packageId, 'channel': pushChannel, }; - final _result = await _dio - .fetch>(_setStreamType(Options( + final _options = _setStreamType(Options( method: 'POST', headers: _headers, extra: _extra, contentType: 'application/x-www-form-urlencoded', ) - .compose( - _dio.options, - '/plugin.php?id=dhpush:token', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - final _value = PostTokenResult.fromJson(_result.data!); + .compose( + _dio.options, + '/plugin.php?id=dhpush:token', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late PostTokenResult _value; + try { + _value = PostTokenResult.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } @@ -1323,25 +1572,31 @@ class _MobileApiClient implements MobileApiClient { 'seccodeverify': verification, 'unused[]': attachAid, }; - final _result = await _dio - .fetch>(_setStreamType(Options( + final _options = _setStreamType(Options( method: 'POST', headers: _headers, extra: _extra, contentType: 'application/x-www-form-urlencoded', ) - .compose( - _dio.options, - '/api/mobile/index.php?version=4&module=newthread&topicsubmit=yes&usesig=1', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - final _value = ApiResult.fromJson(_result.data!); + .compose( + _dio.options, + '/api/mobile/index.php?version=4&module=newthread&topicsubmit=yes&usesig=1', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late ApiResult _value; + try { + _value = ApiResult.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } @@ -1351,25 +1606,31 @@ class _MobileApiClient implements MobileApiClient { final queryParameters = {}; final _headers = {}; final _data = {'hash': formhash}; - final _result = await _dio - .fetch>(_setStreamType(Options( + final _options = _setStreamType(Options( method: 'POST', headers: _headers, extra: _extra, contentType: 'application/x-www-form-urlencoded', ) - .compose( - _dio.options, - '/api/mobile/index.php?version=4&module=mobilesign&type=thread&ac=favorite&deletesubmit=true&op=delete', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - final _value = ApiResult.fromJson(_result.data!); + .compose( + _dio.options, + '/api/mobile/index.php?version=4&module=mobilesign&type=thread&ac=favorite&deletesubmit=true&op=delete', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late ApiResult _value; + try { + _value = ApiResult.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } @@ -1393,25 +1654,31 @@ class _MobileApiClient implements MobileApiClient { 'warned': warned, 'reason': reason, }; - final _result = await _dio - .fetch>(_setStreamType(Options( + final _options = _setStreamType(Options( method: 'POST', headers: _headers, extra: _extra, contentType: 'application/x-www-form-urlencoded', ) - .compose( - _dio.options, - '/api/mobile/index.php?version=4&module=topicadmin&action=warn&modsubmit=yes&sendreasonpm=on', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - final _value = ApiResult.fromJson(_result.data!); + .compose( + _dio.options, + '/api/mobile/index.php?version=4&module=topicadmin&action=warn&modsubmit=yes&sendreasonpm=on', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late ApiResult _value; + try { + _value = ApiResult.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } @@ -1435,25 +1702,31 @@ class _MobileApiClient implements MobileApiClient { 'banned': banned, 'reason': reason, }; - final _result = await _dio - .fetch>(_setStreamType(Options( + final _options = _setStreamType(Options( method: 'POST', headers: _headers, extra: _extra, contentType: 'application/x-www-form-urlencoded', ) - .compose( - _dio.options, - '/api/mobile/index.php?version=4&module=topicadmin&action=banpost&modsubmit=yes&sendreasonpm=on', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - final _value = ApiResult.fromJson(_result.data!); + .compose( + _dio.options, + '/api/mobile/index.php?version=4&module=topicadmin&action=banpost&modsubmit=yes&sendreasonpm=on', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late ApiResult _value; + try { + _value = ApiResult.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } @@ -1477,25 +1750,31 @@ class _MobileApiClient implements MobileApiClient { 'warned': warned, 'reason': reason, }; - final _result = await _dio - .fetch>(_setStreamType(Options( + final _options = _setStreamType(Options( method: 'POST', headers: _headers, extra: _extra, contentType: 'application/x-www-form-urlencoded', ) - .compose( - _dio.options, - '/api/mobile/index.php?version=4&module=topicadmin&action=delpost&modsubmit=yes&sendreasonpm=on', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - final _value = ApiResult.fromJson(_result.data!); + .compose( + _dio.options, + '/api/mobile/index.php?version=4&module=topicadmin&action=delpost&modsubmit=yes&sendreasonpm=on', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late ApiResult _value; + try { + _value = ApiResult.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } diff --git a/lib/client/PushServiceClient.dart b/lib/client/PushServiceClient.dart index 42b84fa0..b3953129 100644 --- a/lib/client/PushServiceClient.dart +++ b/lib/client/PushServiceClient.dart @@ -2,6 +2,7 @@ import 'package:dio/dio.dart'; import 'package:discuz_flutter/JsonResult/SubscribeChannelResult.dart'; import 'package:discuz_flutter/JsonResult/ThreadSlideShowResult.dart'; +import 'package:retrofit/error_logger.dart'; import 'package:retrofit/http.dart'; part 'PushServiceClient.g.dart'; diff --git a/lib/client/PushServiceClient.g.dart b/lib/client/PushServiceClient.g.dart index ac0240f1..10b30982 100644 --- a/lib/client/PushServiceClient.g.dart +++ b/lib/client/PushServiceClient.g.dart @@ -12,6 +12,7 @@ class _PushServiceClient implements PushServiceClient { _PushServiceClient( this._dio, { this.baseUrl, + this.errorLogger, }) { baseUrl ??= 'https://dhp.kidozh.com'; } @@ -20,6 +21,8 @@ class _PushServiceClient implements PushServiceClient { String? baseUrl; + final ParseErrorLogger? errorLogger; + @override Future getAllChannelByHost( String host, @@ -32,24 +35,30 @@ class _PushServiceClient implements PushServiceClient { }; final _headers = {}; const Map? _data = null; - final _result = await _dio.fetch>( - _setStreamType(Options( + final _options = _setStreamType(Options( method: 'GET', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/channel/api', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - final _value = SubscribeChannelResult.fromJson(_result.data!); + .compose( + _dio.options, + '/channel/api', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late SubscribeChannelResult _value; + try { + _value = SubscribeChannelResult.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } @@ -73,24 +82,30 @@ class _PushServiceClient implements PushServiceClient { }; final _headers = {}; const Map? _data = null; - final _result = await _dio.fetch>( - _setStreamType(Options( + final _options = _setStreamType(Options( method: 'POST', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/channel/api', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - final _value = SubscribeChannelResult.fromJson(_result.data!); + .compose( + _dio.options, + '/channel/api', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late SubscribeChannelResult _value; + try { + _value = SubscribeChannelResult.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } @@ -112,24 +127,30 @@ class _PushServiceClient implements PushServiceClient { }; final _headers = {}; const Map? _data = null; - final _result = await _dio.fetch>( - _setStreamType(Options( + final _options = _setStreamType(Options( method: 'PUT', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/channel/api', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - final _value = SubscribeChannelResult.fromJson(_result.data!); + .compose( + _dio.options, + '/channel/api', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late SubscribeChannelResult _value; + try { + _value = SubscribeChannelResult.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } @@ -151,24 +172,30 @@ class _PushServiceClient implements PushServiceClient { }; final _headers = {}; const Map? _data = null; - final _result = await _dio.fetch>( - _setStreamType(Options( + final _options = _setStreamType(Options( method: 'DELETE', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/channel/api', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - final _value = SubscribeChannelResult.fromJson(_result.data!); + .compose( + _dio.options, + '/channel/api', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late SubscribeChannelResult _value; + try { + _value = SubscribeChannelResult.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } @@ -179,24 +206,30 @@ class _PushServiceClient implements PushServiceClient { final queryParameters = {r'host': host}; final _headers = {}; const Map? _data = null; - final _result = await _dio.fetch>( - _setStreamType(Options( + final _options = _setStreamType(Options( method: 'GET', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/customize-slide/api', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - final _value = ThreadSlideShowResult.fromJson(_result.data!); + .compose( + _dio.options, + '/customize-slide/api', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late ThreadSlideShowResult _value; + try { + _value = ThreadSlideShowResult.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } diff --git a/lib/client/UtilityServiceApiClient.dart b/lib/client/UtilityServiceApiClient.dart index 03c1f02e..c76a87d6 100644 --- a/lib/client/UtilityServiceApiClient.dart +++ b/lib/client/UtilityServiceApiClient.dart @@ -1,7 +1,6 @@ import 'package:dio/dio.dart'; -import 'package:discuz_flutter/JsonResult/SubscribeChannelResult.dart'; -import 'package:discuz_flutter/JsonResult/ThreadSlideShowResult.dart'; +import 'package:retrofit/error_logger.dart'; import 'package:retrofit/http.dart'; part 'UtilityServiceApiClient.g.dart'; diff --git a/lib/client/UtilityServiceApiClient.g.dart b/lib/client/UtilityServiceApiClient.g.dart index 08358c17..c2a4ecf5 100644 --- a/lib/client/UtilityServiceApiClient.g.dart +++ b/lib/client/UtilityServiceApiClient.g.dart @@ -12,6 +12,7 @@ class _UtilityServiceApiClient implements UtilityServiceApiClient { _UtilityServiceApiClient( this._dio, { this.baseUrl, + this.errorLogger, }) { baseUrl ??= 'https://discuzhub.kidozh.com'; } @@ -20,13 +21,15 @@ class _UtilityServiceApiClient implements UtilityServiceApiClient { String? baseUrl; + final ParseErrorLogger? errorLogger; + @override Future getAllSuggestedDiscuzList() async { final _extra = {}; final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _result = await _dio.fetch(_setStreamType(Options( + final _options = _setStreamType(Options( method: 'GET', headers: _headers, extra: _extra, @@ -41,8 +44,15 @@ class _UtilityServiceApiClient implements UtilityServiceApiClient { baseUrl: _combineBaseUrls( _dio.options.baseUrl, baseUrl, - )))); - final _value = _result.data!; + ))); + final _result = await _dio.fetch(_options); + late String _value; + try { + _value = _result.data!; + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } diff --git a/lib/entity/DiscuzError.dart b/lib/entity/DiscuzError.dart index efeeffdc..b1e01c69 100644 --- a/lib/entity/DiscuzError.dart +++ b/lib/entity/DiscuzError.dart @@ -5,7 +5,8 @@ class DiscuzError{ String key = "", content = ""; ErrorType? errorType = null; DioException? dioError = null; - DiscuzError(this.key,this.content, {this.errorType, this.dioError}); + DiscuzError(this.key,this.content, {this.errorType, this.dioError, this.errorURL}); + String? errorURL = ""; } diff --git a/lib/generated/intl/messages_en.dart b/lib/generated/intl/messages_en.dart index 0e6f6e5e..6bcc16fa 100644 --- a/lib/generated/intl/messages_en.dart +++ b/lib/generated/intl/messages_en.dart @@ -152,6 +152,11 @@ class MessageLookup extends MessageLookupByLibrary { MessageLookupByLibrary.simpleMessage("AD provided by Google"), "addAPhoto": MessageLookupByLibrary.simpleMessage("Photo"), "addAuthentication": MessageLookupByLibrary.simpleMessage("Add"), + "addDiscuzApiBrowseUnsuccessfully": + MessageLookupByLibrary.simpleMessage( + "Unable to recognise the discuz!"), + "addDiscuzApiParseUnsuccessfully": MessageLookupByLibrary.simpleMessage( + "The mobile plugin is not recognisable."), "addDiscuzSuccessfully": m0, "addDiscuzSuggestionAnnotation": MessageLookupByLibrary.simpleMessage("Feedback"), @@ -187,6 +192,11 @@ class MessageLookup extends MessageLookupByLibrary { MessageLookupByLibrary.simpleMessage( "Choose the app appearance on preferred platform."), "attachFile": m1, + "attachmentUploadExceedingSizeDescription": + MessageLookupByLibrary.simpleMessage( + "The attachment shall be compressed to be accepted by the forum."), + "attachmentUploadExceedingSizeTitle": + MessageLookupByLibrary.simpleMessage("The attachment is too large"), "authenticateBySystem": MessageLookupByLibrary.simpleMessage( "Please authenticate to query saved password."), "authenticationEmpty": MessageLookupByLibrary.simpleMessage( @@ -988,8 +998,8 @@ class MessageLookup extends MessageLookupByLibrary { "Due to ongoing incidences, push notification service has been terminated."), "upgrade_notification_title": MessageLookupByLibrary.simpleMessage("Service termination"), - "uploadCompressedImageToServer": MessageLookupByLibrary.simpleMessage( - "Send compressed image(Recommended)"), + "uploadCompressedImageToServer": + MessageLookupByLibrary.simpleMessage("Send compressed image"), "uploadImageError1": MessageLookupByLibrary.simpleMessage( "The file extension is not supported."), "uploadImageError10": diff --git a/lib/generated/intl/messages_zh_CN.dart b/lib/generated/intl/messages_zh_CN.dart index 3fc3c696..c60d6ea5 100644 --- a/lib/generated/intl/messages_zh_CN.dart +++ b/lib/generated/intl/messages_zh_CN.dart @@ -148,6 +148,10 @@ class MessageLookup extends MessageLookupByLibrary { MessageLookupByLibrary.simpleMessage("由Google提供的广告,与论坛无关。"), "addAPhoto": MessageLookupByLibrary.simpleMessage("照片"), "addAuthentication": MessageLookupByLibrary.simpleMessage("添加到凭证集中"), + "addDiscuzApiBrowseUnsuccessfully": + MessageLookupByLibrary.simpleMessage("无法识别论坛掌上论坛插件,请联系管理员开启本插件。"), + "addDiscuzApiParseUnsuccessfully": MessageLookupByLibrary.simpleMessage( + "掌上论坛API插件未被正确配置,其返回了一个无法识别的错误,。"), "addDiscuzSuccessfully": m0, "addDiscuzSuggestionAnnotation": MessageLookupByLibrary.simpleMessage("反馈问题"), @@ -180,6 +184,10 @@ class MessageLookup extends MessageLookupByLibrary { "appearanceOptimizedPlatformSubtitle": MessageLookupByLibrary.simpleMessage("你可以选择对应平台下应用的显示样式"), "attachFile": m1, + "attachmentUploadExceedingSizeDescription": + MessageLookupByLibrary.simpleMessage("附件需要被压缩以满足限额"), + "attachmentUploadExceedingSizeTitle": + MessageLookupByLibrary.simpleMessage("上传的附件超出了论坛限制大小"), "authenticateBySystem": MessageLookupByLibrary.simpleMessage("请验证您的身份以查看本地存储的保存密码。"), "authenticationEmpty": @@ -847,7 +855,7 @@ class MessageLookup extends MessageLookupByLibrary { "upgrade_notification_title": MessageLookupByLibrary.simpleMessage("服务终止"), "uploadCompressedImageToServer": - MessageLookupByLibrary.simpleMessage("适当压缩的图片(推荐)"), + MessageLookupByLibrary.simpleMessage("发送压缩图片"), "uploadImageError1": MessageLookupByLibrary.simpleMessage("不支持此类扩展名."), "uploadImageError10": MessageLookupByLibrary.simpleMessage("非法操作"), "uploadImageError11": @@ -874,7 +882,7 @@ class MessageLookup extends MessageLookupByLibrary { "uploadImageUnknownError": MessageLookupByLibrary.simpleMessage("上传文件时遇到了一个未知错误。"), "uploadRawImageToServer": - MessageLookupByLibrary.simpleMessage("原始图片(可能因为太大被服务器拒绝)"), + MessageLookupByLibrary.simpleMessage("发送原始图片"), "uploadTokenSuccessful": MessageLookupByLibrary.simpleMessage("您的设备令牌已经成功传入到论坛中。"), "uploadTokenUnsuccessful": diff --git a/lib/generated/l10n.dart b/lib/generated/l10n.dart index 3d0bc3e2..43815237 100644 --- a/lib/generated/l10n.dart +++ b/lib/generated/l10n.dart @@ -2921,10 +2921,10 @@ class S { ); } - /// `Send compressed image(Recommended)` + /// `Send compressed image` String get uploadCompressedImageToServer { return Intl.message( - 'Send compressed image(Recommended)', + 'Send compressed image', name: 'uploadCompressedImageToServer', desc: '', args: [], @@ -5870,6 +5870,46 @@ class S { args: [], ); } + + /// `The attachment is too large` + String get attachmentUploadExceedingSizeTitle { + return Intl.message( + 'The attachment is too large', + name: 'attachmentUploadExceedingSizeTitle', + desc: '', + args: [], + ); + } + + /// `The attachment shall be compressed to be accepted by the forum.` + String get attachmentUploadExceedingSizeDescription { + return Intl.message( + 'The attachment shall be compressed to be accepted by the forum.', + name: 'attachmentUploadExceedingSizeDescription', + desc: '', + args: [], + ); + } + + /// `Unable to recognise the discuz!` + String get addDiscuzApiBrowseUnsuccessfully { + return Intl.message( + 'Unable to recognise the discuz!', + name: 'addDiscuzApiBrowseUnsuccessfully', + desc: '', + args: [], + ); + } + + /// `The mobile plugin is not recognisable.` + String get addDiscuzApiParseUnsuccessfully { + return Intl.message( + 'The mobile plugin is not recognisable.', + name: 'addDiscuzApiParseUnsuccessfully', + desc: '', + args: [], + ); + } } class AppLocalizationDelegate extends LocalizationsDelegate { diff --git a/lib/l10n/intl_en.arb b/lib/l10n/intl_en.arb index 34e5ab68..90a388ab 100644 --- a/lib/l10n/intl_en.arb +++ b/lib/l10n/intl_en.arb @@ -438,7 +438,7 @@ "noSmileyFoundInDB": "Try to use the first smiley?", "uploadImageFailed": "Upload image failed", "uploadingImageToServer": "Upload the file to the server...", - "uploadCompressedImageToServer": "Send compressed image(Recommended)", + "uploadCompressedImageToServer": "Send compressed image", "uploadRawImageToServer": "Send raw image", "threadIsClosed": "Thread is closed.", "blockUser": "Block user", @@ -848,5 +848,9 @@ "adExemptCondition": "As a gift, you can opt one discuz forum out of advertisement.", "adExemptEmbeddedList": "The following discuz forums have already been exempted out of advertisement.", "adExemptNeedConfirm": "Choose one discuz to exempt AD", - "adExemptNoNeedToConfirm": "There is no discuz forum needs to opt out of advertisement" + "adExemptNoNeedToConfirm": "There is no discuz forum needs to opt out of advertisement", + "attachmentUploadExceedingSizeTitle": "The attachment is too large", + "attachmentUploadExceedingSizeDescription": "The attachment shall be compressed to be accepted by the forum.", + "addDiscuzApiBrowseUnsuccessfully": "Unable to recognise the discuz!", + "addDiscuzApiParseUnsuccessfully": "The mobile plugin is not recognisable." } \ No newline at end of file diff --git a/lib/l10n/intl_zh_CN.arb b/lib/l10n/intl_zh_CN.arb index fe2d5d86..0f9fcaec 100644 --- a/lib/l10n/intl_zh_CN.arb +++ b/lib/l10n/intl_zh_CN.arb @@ -438,8 +438,8 @@ "noSmileyFoundInDB": "要不使用一个表情包?", "uploadImageFailed": "上传图片失败", "uploadingImageToServer": "向服务器传输数据中。。。", - "uploadCompressedImageToServer": "适当压缩的图片(推荐)", - "uploadRawImageToServer": "原始图片(可能因为太大被服务器拒绝)", + "uploadCompressedImageToServer": "发送压缩图片", + "uploadRawImageToServer": "发送原始图片", "threadIsClosed": "此贴已关闭发帖。", "blockUser": "屏蔽此用户", "unblockUser": "解除屏蔽", @@ -849,5 +849,9 @@ "adExemptCondition": "感谢您使用应用小尾巴,你可以选择一个论坛不显示其所有的广告。", "adExemptEmbeddedList": "下列Discuz论坛已经内置于广告白名单中。", "adExemptNeedConfirm": "选择下列论坛免广告", - "adExemptNoNeedToConfirm": "目前还没有需要免广告的论坛站点" + "adExemptNoNeedToConfirm": "目前还没有需要免广告的论坛站点", + "attachmentUploadExceedingSizeTitle": "上传的附件超出了论坛限制大小", + "attachmentUploadExceedingSizeDescription": "附件需要被压缩以满足限额", + "addDiscuzApiBrowseUnsuccessfully": "无法识别论坛掌上论坛插件,请联系管理员开启本插件。", + "addDiscuzApiParseUnsuccessfully": "掌上论坛API插件未被正确配置,其返回了一个无法识别的错误,。" } \ No newline at end of file diff --git a/lib/page/AddDiscuzPage.dart b/lib/page/AddDiscuzPage.dart index 4ecb7ad2..eae5ea91 100644 --- a/lib/page/AddDiscuzPage.dart +++ b/lib/page/AddDiscuzPage.dart @@ -1,6 +1,5 @@ import 'dart:convert'; import 'dart:developer'; -import 'dart:io'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:dio/dio.dart'; @@ -80,7 +79,7 @@ class _AddDiscuzFormFieldState setState(() { supportDiscuzListResult = _supportDiscuzListResult; }); - } catch (e, s) {} + } catch (e) {} final dio = Dio(); final client = @@ -95,7 +94,7 @@ class _AddDiscuzFormFieldState }); // then cache it UserPreferencesUtils.putSupportDiscuzListResultCacheJson(string); - } catch (e, s) {} + } catch (e) {} }); } @@ -141,7 +140,7 @@ class _AddDiscuzFormFieldState setState(() { _isLoading = false; }); - log(value.toString()); + // log(value.toString()); // convert string to json Map checkResultJson = jsonDecode(value); CheckResult checkResult = CheckResult.fromJson(checkResultJson); @@ -156,16 +155,21 @@ class _AddDiscuzFormFieldState setState(() { _isLoading = false; }); + log("GET ADD discuz error ${onError}"); if (onError is DioException) { - //log("GET ADD discuz error ${onError}"); + DioException dioError = onError; - error = DiscuzError(dioError.type.name, - dioError.message == null ? S.of(context).error : dioError.message!, + error = DiscuzError("AddDiscuzDioException", + S.of(context).addDiscuzApiBrowseUnsuccessfully, + errorURL: _urlController.text, dioError: dioError); } else { //log("GET ADD discuz error NOT in DIO ${onError}"); setState(() { - error = DiscuzError("", onError.toString()); + error = DiscuzError("AddDiscuzParseError", + errorURL: _urlController.text, + S.of(context).addDiscuzApiParseUnsuccessfully, + ); }); } }); @@ -188,7 +192,7 @@ class _AddDiscuzFormFieldState decoration: isCupertino(context) ? BoxDecoration( borderRadius: BorderRadius.circular(8), - color: Theme.of(context).disabledColor.withOpacity(0.1)) + color: Theme.of(context).disabledColor.withOpacity(0.05)) : null, child: PlatformTextFormField( controller: _urlController, diff --git a/lib/page/ChooseDynamicSchemeVariantPage.dart b/lib/page/ChooseDynamicSchemeVariantPage.dart index 676fa4b9..3c29b6a5 100644 --- a/lib/page/ChooseDynamicSchemeVariantPage.dart +++ b/lib/page/ChooseDynamicSchemeVariantPage.dart @@ -6,7 +6,6 @@ import 'package:discuz_flutter/utility/AppPlatformIcons.dart'; import 'package:discuz_flutter/utility/UserPreferencesUtils.dart'; import 'package:discuz_flutter/utility/VibrationUtils.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_html/flutter_html.dart'; import 'package:flutter_platform_widgets/flutter_platform_widgets.dart'; import 'package:provider/provider.dart'; import 'package:settings_ui/settings_ui.dart'; diff --git a/lib/page/DrawerPage.dart b/lib/page/DrawerPage.dart index df204988..b7e1b84a 100644 --- a/lib/page/DrawerPage.dart +++ b/lib/page/DrawerPage.dart @@ -13,7 +13,6 @@ import 'package:discuz_flutter/utility/CustomizeColor.dart'; import 'package:discuz_flutter/utility/VibrationUtils.dart'; import 'package:discuz_flutter/widget/UserAvatar.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_html/flutter_html.dart'; import 'package:flutter_platform_widgets/flutter_platform_widgets.dart'; import 'package:hive_flutter/hive_flutter.dart'; import 'package:provider/provider.dart'; diff --git a/lib/page/SettingPage.dart b/lib/page/SettingPage.dart index 0c19f664..e023cfad 100644 --- a/lib/page/SettingPage.dart +++ b/lib/page/SettingPage.dart @@ -21,7 +21,6 @@ import 'package:settings_ui/settings_ui.dart'; import 'package:url_launcher/url_launcher.dart'; import '../utility/AppPlatformIcons.dart'; -import '../utility/CustomizeColor.dart'; import '../utility/PostTextFieldUtils.dart'; import 'ChooseThemeColorPage.dart'; diff --git a/lib/screen/DashboardScreen.dart b/lib/screen/DashboardScreen.dart index dc0d98cd..988af55e 100644 --- a/lib/screen/DashboardScreen.dart +++ b/lib/screen/DashboardScreen.dart @@ -11,7 +11,6 @@ import 'package:flutter_platform_widgets/flutter_platform_widgets.dart'; import 'package:provider/provider.dart'; import '../generated/l10n.dart'; -import '../utility/CustomizeColor.dart'; import 'HotThreadScreen.dart'; class DashboardScreen extends StatelessWidget{ diff --git a/lib/screen/ExtraFuncInThreadScreen.dart b/lib/screen/ExtraFuncInThreadScreen.dart index 472ab068..f87b7c7b 100644 --- a/lib/screen/ExtraFuncInThreadScreen.dart +++ b/lib/screen/ExtraFuncInThreadScreen.dart @@ -1,5 +1,6 @@ +import 'dart:developer'; import 'dart:io'; import 'package:discuz_flutter/JsonResult/CheckPostResult.dart'; @@ -119,6 +120,10 @@ class ExtraFuncInThreadState extends State{ // then upload to the server if(image != null){ XFile file = XFile(image.path); + // check with the size + int file_size = await file.length(); + bool file_not_exceeding_size = file_size < _checkPostResult.variables.allowPerm.attachRemain.size; + log("Get file size ${file_size} <-> ${_checkPostResult.variables.allowPerm.attachRemain.size} HASH ${_checkPostResult.variables.allowPerm.uploadHash}"); // confirm with user showPlatformDialog( context: context, @@ -127,16 +132,40 @@ class ExtraFuncInThreadState extends State{ return PlatformAlertDialog( title: Text(S.of(context).uploadImageToServerDialogTitle), content: Column( + mainAxisSize: MainAxisSize.min, children: [ if(isUploadingPicture) ListTile( leading: PlatformCircularProgressIndicator(), title: Text(S.of(context).uploadingImageToServer), ), + if(!file_not_exceeding_size) + Container( + child: PlatformListTile( + // title: Text(S.of(context).attachmentUploadExceedingSizeTitle, + // style: TextStyle( + // color: Theme.of(context).colorScheme.onPrimary, + // fontSize: FontSize.small.value + // ), + // + // ), + title: Text(S.of(context).attachmentUploadExceedingSizeDescription, + style: TextStyle( + color: Theme.of(context).colorScheme.onPrimary, + ), + ), + ), + padding: EdgeInsets.all(4.0), + decoration: BoxDecoration( + color: Theme.of(context).colorScheme.primary, + ), + ), Image.file(File(file.path)), + ], ), actions: [ + PlatformDialogAction( child: Text(S.of(context).uploadCompressedImageToServer), onPressed: () async{ @@ -170,6 +199,7 @@ class ExtraFuncInThreadState extends State{ Navigator.of(context).pop(); }, ), + if(file_not_exceeding_size) PlatformDialogAction( child: Text(S.of(context).uploadRawImageToServer), onPressed: () async{ @@ -214,6 +244,8 @@ class ExtraFuncInThreadState extends State{ final XFile? image = await _picker.pickImage(source: ImageSource.camera); if(image != null){ File file = File(image.path); + int file_size = await file.length(); + bool file_not_exceeding_size = file_size > _checkPostResult.variables.allowPerm.attachRemain.size; showPlatformDialog( context: context, @@ -266,6 +298,7 @@ class ExtraFuncInThreadState extends State{ Navigator.of(context).pop(); }, ), + if(file_not_exceeding_size) PlatformDialogAction( child: Text(S.of(context).uploadRawImageToServer), onPressed: () async{ diff --git a/lib/screen/PrivateMessagePortalScreen.dart b/lib/screen/PrivateMessagePortalScreen.dart index 7e508fff..1a49e281 100644 --- a/lib/screen/PrivateMessagePortalScreen.dart +++ b/lib/screen/PrivateMessagePortalScreen.dart @@ -67,7 +67,7 @@ class _PrivateMessagePortalState User? user = Provider.of(context, listen: false).user; if(discuz!= null && user!= null){ - String jsonString = await UserPreferencesUtils.getDiscuzPrivateMessageResultCacheJson(discuz, user!); + String jsonString = await UserPreferencesUtils.getDiscuzPrivateMessageResultCacheJson(discuz, user); try{ PrivateMessagePortalResult cacheResult = PrivateMessagePortalResult.fromJson(jsonDecode(jsonString)); log("Set state ->"); @@ -76,7 +76,7 @@ class _PrivateMessagePortalState _pmList = cacheResult.variables.pmList; }); } - catch(e,s){ + catch(e){ log(e.toString()); } @@ -115,7 +115,7 @@ class _PrivateMessagePortalState return await _client.privateMessagePortalResult(_page).then((value) async{ String cacheString = jsonEncode(value.toJson()); - await UserPreferencesUtils.putDiscuzPrivateMessageResultCacheJson(discuz, user!, cacheString); + await UserPreferencesUtils.putDiscuzPrivateMessageResultCacheJson(discuz, user, cacheString); setState(() { result = value; _error = null; @@ -137,7 +137,7 @@ class _PrivateMessagePortalState : IndicatorResult.success); - if (user != null && value.variables.member_uid != user.uid) { + if (value.variables.member_uid != user.uid) { setState(() { _error = DiscuzError(S.of(context).userExpiredTitle(user.username), S.of(context).userExpiredSubtitle); diff --git a/lib/widget/AppBannerAdWidget.dart b/lib/widget/AppBannerAdWidget.dart index 543b3e3a..16fbc38d 100644 --- a/lib/widget/AppBannerAdWidget.dart +++ b/lib/widget/AppBannerAdWidget.dart @@ -6,7 +6,6 @@ import 'package:google_mobile_ads/google_mobile_ads.dart'; import 'package:provider/provider.dart'; import '../entity/Discuz.dart'; -import '../generated/l10n.dart'; import '../provider/DiscuzAndUserNotifier.dart'; import '../provider/UserPreferenceNotifierProvider.dart'; diff --git a/lib/widget/DiscuzHtmlWidget.dart b/lib/widget/DiscuzHtmlWidget.dart index f7eec735..014ccd87 100644 --- a/lib/widget/DiscuzHtmlWidget.dart +++ b/lib/widget/DiscuzHtmlWidget.dart @@ -200,14 +200,14 @@ class DiscuzHtmlWidget extends StatelessWidget{ const AudioHtmlExtension(), const TableHtmlExtension(), const VideoHtmlExtension(), - TagWrapExtension( - tagsToWrap: {"table"}, - builder: (child) { - return SingleChildScrollView( - scrollDirection: Axis.horizontal, - child: child, - ); - }), + // TagWrapExtension( + // tagsToWrap: {"table"}, + // builder: (child) { + // return SingleChildScrollView( + // scrollDirection: Axis.horizontal, + // child: child, + // ); + // }), ImageExtension( //matchesAssetImages: false, //matchesDataImages: false, diff --git a/lib/widget/ErrorCard.dart b/lib/widget/ErrorCard.dart index 8ff2b714..619ca086 100644 --- a/lib/widget/ErrorCard.dart +++ b/lib/widget/ErrorCard.dart @@ -8,6 +8,7 @@ import 'package:discuz_flutter/utility/VibrationUtils.dart'; import 'package:flutter/material.dart'; import 'package:flutter_platform_widgets/flutter_platform_widgets.dart'; import 'package:provider/provider.dart'; +import 'package:url_launcher/url_launcher.dart'; import '../entity/Discuz.dart'; import '../entity/DiscuzError.dart'; @@ -78,6 +79,16 @@ class ErrorCard extends StatelessWidget{ onRefreshCallback!(); }, ), + if(discuzError.key == "AddDiscuzParseError" || discuzError.key == "AddDiscuzDioException") + TextButton( + child: Text(S.of(context).contactUsViaEmail), + onPressed: () async{ + VibrationUtils.vibrateWithClickIfPossible(); + await launchUrl(Uri.parse("mailto:kidozh@gmail.com?subject=${discuzError.errorURL == null?"":discuzError.errorURL}")); + //Navigator.of(context).pop(); + }, + + ), if(errorType == ErrorType.userExpired) // should directly re-login here TextButton( diff --git a/lib/widget/PostWidget.dart b/lib/widget/PostWidget.dart index b9cc1ec9..926a341d 100644 --- a/lib/widget/PostWidget.dart +++ b/lib/widget/PostWidget.dart @@ -24,7 +24,6 @@ import 'package:discuz_flutter/utility/VibrationUtils.dart'; import 'package:discuz_flutter/widget/AttachmentWidget.dart'; import 'package:discuz_flutter/widget/DiscuzHtmlWidget.dart'; import 'package:discuz_flutter/widget/PostCommentWidget.dart'; -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_html/flutter_html.dart'; diff --git a/lib/widget/PrivateMessagePortalWidget.dart b/lib/widget/PrivateMessagePortalWidget.dart index 37808811..8882c8d9 100644 --- a/lib/widget/PrivateMessagePortalWidget.dart +++ b/lib/widget/PrivateMessagePortalWidget.dart @@ -1,14 +1,9 @@ -import 'package:cached_network_image/cached_network_image.dart'; import 'package:discuz_flutter/JsonResult/PrivateMessagePortalResult.dart'; import 'package:discuz_flutter/entity/Discuz.dart'; import 'package:discuz_flutter/entity/User.dart'; -import 'package:discuz_flutter/generated/l10n.dart'; import 'package:discuz_flutter/page/PrivateMessageDetailPage.dart'; -import 'package:discuz_flutter/page/UserProfilePage.dart'; import 'package:discuz_flutter/provider/DiscuzAndUserNotifier.dart'; -import 'package:discuz_flutter/utility/CustomizeColor.dart'; -import 'package:discuz_flutter/utility/URLUtils.dart'; import 'package:discuz_flutter/utility/VibrationUtils.dart'; import 'package:discuz_flutter/widget/UserAvatar.dart'; import 'package:flutter/material.dart';