From 682e1af2c05bd2009b9bdddbc10d5a527feb76b7 Mon Sep 17 00:00:00 2001 From: Filip Krawczyk Date: Fri, 14 Jan 2022 14:25:31 +0100 Subject: [PATCH] Lemmy v0.15.0 changes (#314) --- ios/Podfile.lock | 10 ++-- ios/Runner.xcodeproj/project.pbxproj | 2 +- lib/pages/instance.dart | 28 +++++------ lib/pages/settings/add_account_page.dart | 9 ++++ lib/stores/accounts_store.dart | 27 ++++++++++- pubspec.lock | 59 +++++++++++++----------- pubspec.yaml | 2 +- test/stores/config_store_test.dart | 2 + 8 files changed, 91 insertions(+), 48 deletions(-) diff --git a/ios/Podfile.lock b/ios/Podfile.lock index c843e55..87527db 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -12,7 +12,7 @@ PODS: - Flutter - shared_preferences_ios (0.0.1): - Flutter - - url_launcher (0.0.1): + - url_launcher_ios (0.0.1): - Flutter DEPENDENCIES: @@ -23,7 +23,7 @@ DEPENDENCIES: - path_provider_ios (from `.symlinks/plugins/path_provider_ios/ios`) - share_plus (from `.symlinks/plugins/share_plus/ios`) - shared_preferences_ios (from `.symlinks/plugins/shared_preferences_ios/ios`) - - url_launcher (from `.symlinks/plugins/url_launcher/ios`) + - url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`) EXTERNAL SOURCES: Flutter: @@ -40,8 +40,8 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/share_plus/ios" shared_preferences_ios: :path: ".symlinks/plugins/shared_preferences_ios/ios" - url_launcher: - :path: ".symlinks/plugins/url_launcher/ios" + url_launcher_ios: + :path: ".symlinks/plugins/url_launcher_ios/ios" SPEC CHECKSUMS: Flutter: 50d75fe2f02b26cc09d224853bb45737f8b3214a @@ -51,7 +51,7 @@ SPEC CHECKSUMS: path_provider_ios: 7d7ce634493af4477d156294792024ec3485acd5 share_plus: 056a1e8ac890df3e33cb503afffaf1e9b4fbae68 shared_preferences_ios: aef470a42dc4675a1cdd50e3158b42e3d1232b32 - url_launcher: b6e016d912f04be9f5bf6e8e82dc599b7ba59649 + url_launcher_ios: 02f1989d4e14e998335b02b67a7590fa34f971af PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index bbbd5af..8a1d6dd 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -173,7 +173,7 @@ 97C146E61CF9000F007C117D /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 1250; + LastUpgradeCheck = 1300; ORGANIZATIONNAME = ""; TargetAttributes = { 97C146ED1CF9000F007C117D = { diff --git a/lib/pages/instance.dart b/lib/pages/instance.dart index 33e5ba3..46d6d6e 100644 --- a/lib/pages/instance.dart +++ b/lib/pages/instance.dart @@ -21,7 +21,6 @@ import '../widgets/sortable_infinite_list.dart'; import '../widgets/user_tile.dart'; import 'communities_list.dart'; import 'modlog/modlog.dart'; -import 'users_list.dart'; /// Displays posts, comments, and general info about the given instance class InstancePage extends HookWidget { @@ -220,15 +219,15 @@ class _AboutTab extends HookWidget { required this.instanceHost, }); - void goToBannedUsers(BuildContext context) { - goTo( - context, - (_) => UsersListPage( - users: site.banned.reversed.toList(), - title: L10n.of(context).banned_users, - ), - ); - } + // void goToBannedUsers(BuildContext context) { + // goTo( + // context, + // (_) => UsersListPage( + // users: site.banned.reversed.toList(), + // title: L10n.of(context).banned_users, + // ), + // ); + // } @override Widget build(BuildContext context) { @@ -359,10 +358,11 @@ class _AboutTab extends HookWidget { expanded: true, ), const _Divider(), - ListTile( - title: Center(child: Text(L10n.of(context).banned_users)), - onTap: () => goToBannedUsers(context), - ), + // TODO: transition to new API + // ListTile( + // title: Center(child: Text(L10n.of(context).banned_users)), + // onTap: () => goToBannedUsers(context), + // ), ListTile( title: Center(child: Text(L10n.of(context).modlog)), onTap: () => Navigator.of(context).push( diff --git a/lib/pages/settings/add_account_page.dart b/lib/pages/settings/add_account_page.dart index 4e24dfe..aeccfd7 100644 --- a/lib/pages/settings/add_account_page.dart +++ b/lib/pages/settings/add_account_page.dart @@ -7,6 +7,7 @@ import 'package:url_launcher/url_launcher.dart' as ul; import '../../hooks/delayed_loading.dart'; import '../../hooks/stores.dart'; import '../../l10n/l10n.dart'; +import '../../stores/accounts_store.dart'; import '../../stores/config_store.dart'; import '../../widgets/cached_network_image.dart'; import '../../widgets/fullscreenable_image.dart'; @@ -63,6 +64,14 @@ class AddAccountPage extends HookWidget { } Navigator.of(context).pop(); + } on VerifyEmailException { + ScaffoldMessenger.of(context).showSnackBar(const SnackBar( + content: Text('Verification email sent'), + )); + } on RegistrationApplicationSentException { + ScaffoldMessenger.of(context).showSnackBar(const SnackBar( + content: Text('Registration application sent'), + )); } on Exception catch (err) { ScaffoldMessenger.of(context).showSnackBar(SnackBar( content: Text(err.toString()), diff --git a/lib/stores/accounts_store.dart b/lib/stores/accounts_store.dart index 3d1ac33..93355b4 100644 --- a/lib/stores/accounts_store.dart +++ b/lib/stores/accounts_store.dart @@ -187,10 +187,19 @@ class AccountsStore extends ChangeNotifier { } final lemmy = LemmyApiV3(instanceHost); - final jwt = await lemmy.run(Login( + final response = await lemmy.run(Login( usernameOrEmail: usernameOrEmail, password: password, )); + final jwt = response.jwt; + if (jwt == null) { + if (response.verifyEmailSent) { + throw const VerifyEmailException(); + } else if (response.registrationCreated) { + throw const RegistrationApplicationSentException(); + } + throw Exception('Unknown error'); // should never happen + } final userData = await lemmy .run(GetSite(auth: jwt.raw)) .then((value) => value.myUser!.localUserView.person); @@ -269,3 +278,19 @@ class UserData { Map toJson() => _$UserDataToJson(this); } +//if (data.verify_email_sent) { +// toast(i18n.t("verify_email_sent")); +// } +// if (data.registration_created) { +// toast(i18n.t("registration_application_sent")); +// } + +class VerifyEmailException implements Exception { + final message = 'verify_email_sent'; + const VerifyEmailException(); +} + +class RegistrationApplicationSentException implements Exception { + final message = 'registration_application_sent'; + const RegistrationApplicationSentException(); +} diff --git a/pubspec.lock b/pubspec.lock index bdd5277..675dcba 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,14 +7,14 @@ packages: name: _fe_analyzer_shared url: "https://pub.dartlang.org" source: hosted - version: "32.0.0" + version: "33.0.0" analyzer: dependency: transitive description: name: analyzer url: "https://pub.dartlang.org" source: hosted - version: "3.0.0" + version: "3.1.0" archive: dependency: transitive description: @@ -98,7 +98,7 @@ packages: name: built_value url: "https://pub.dartlang.org" source: hosted - version: "8.1.3" + version: "8.1.4" characters: dependency: transitive description: @@ -189,7 +189,7 @@ packages: name: extended_image_library url: "https://pub.dartlang.org" source: hosted - version: "3.1.1" + version: "3.1.2" fake_async: dependency: transitive description: @@ -236,7 +236,7 @@ packages: name: flutter_keyboard_visibility url: "https://pub.dartlang.org" source: hosted - version: "5.1.0" + version: "5.1.1" flutter_keyboard_visibility_platform_interface: dependency: transitive description: @@ -384,7 +384,7 @@ packages: name: image url: "https://pub.dartlang.org" source: hosted - version: "3.1.0" + version: "3.1.1" image_picker: dependency: "direct main" description: @@ -398,14 +398,14 @@ packages: name: image_picker_for_web url: "https://pub.dartlang.org" source: hosted - version: "2.1.4" + version: "2.1.5" image_picker_platform_interface: dependency: transitive description: name: image_picker_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.4.1" + version: "2.4.3" intl: dependency: "direct main" description: @@ -440,7 +440,7 @@ packages: name: json_serializable url: "https://pub.dartlang.org" source: hosted - version: "6.1.3" + version: "6.1.4" keyboard_dismisser: dependency: "direct main" description: @@ -461,7 +461,7 @@ packages: name: lemmy_api_client url: "https://pub.dartlang.org" source: hosted - version: "0.18.0" + version: "0.19.0" logging: dependency: "direct main" description: @@ -615,28 +615,35 @@ packages: name: path_provider_linux url: "https://pub.dartlang.org" source: hosted - version: "2.1.4" + version: "2.1.5" path_provider_macos: dependency: transitive description: name: path_provider_macos url: "https://pub.dartlang.org" source: hosted - version: "2.0.4" + version: "2.0.5" path_provider_platform_interface: dependency: transitive description: name: path_provider_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.0.1" + version: "2.0.3" path_provider_windows: dependency: transitive description: name: path_provider_windows url: "https://pub.dartlang.org" source: hosted - version: "2.0.4" + version: "2.0.5" + pedantic: + dependency: transitive + description: + name: pedantic + url: "https://pub.dartlang.org" + source: hosted + version: "1.11.1" petitparser: dependency: transitive description: @@ -664,7 +671,7 @@ packages: name: plugin_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.1.2" pool: dependency: transitive description: @@ -748,28 +755,28 @@ packages: name: shared_preferences url: "https://pub.dartlang.org" source: hosted - version: "2.0.11" + version: "2.0.12" shared_preferences_android: dependency: transitive description: name: shared_preferences_android url: "https://pub.dartlang.org" source: hosted - version: "2.0.9" + version: "2.0.10" shared_preferences_ios: dependency: transitive description: name: shared_preferences_ios url: "https://pub.dartlang.org" source: hosted - version: "2.0.8" + version: "2.0.9" shared_preferences_linux: dependency: transitive description: name: shared_preferences_linux url: "https://pub.dartlang.org" source: hosted - version: "2.0.3" + version: "2.0.4" shared_preferences_macos: dependency: transitive description: @@ -790,14 +797,14 @@ packages: name: shared_preferences_web url: "https://pub.dartlang.org" source: hosted - version: "2.0.2" + version: "2.0.3" shared_preferences_windows: dependency: transitive description: name: shared_preferences_windows url: "https://pub.dartlang.org" source: hosted - version: "2.0.3" + version: "2.0.4" shelf: dependency: transitive description: @@ -907,21 +914,21 @@ packages: name: url_launcher url: "https://pub.dartlang.org" source: hosted - version: "6.0.17" + version: "6.0.18" url_launcher_android: dependency: transitive description: name: url_launcher_android url: "https://pub.dartlang.org" source: hosted - version: "6.0.13" + version: "6.0.14" url_launcher_ios: dependency: transitive description: name: url_launcher_ios url: "https://pub.dartlang.org" source: hosted - version: "6.0.13" + version: "6.0.14" url_launcher_linux: dependency: transitive description: @@ -942,14 +949,14 @@ packages: name: url_launcher_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.0.4" + version: "2.0.5" url_launcher_web: dependency: transitive description: name: url_launcher_web url: "https://pub.dartlang.org" source: hosted - version: "2.0.5" + version: "2.0.6" url_launcher_windows: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 835fc08..b961154 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -47,7 +47,7 @@ dependencies: # utils timeago: ^3.0.2 fuzzy: ^0.4.0-nullsafety.0 - lemmy_api_client: ^0.18.0 + lemmy_api_client: ^0.19.0 intl: ^0.17.0 matrix4_transform: ^2.0.0 json_annotation: ^4.3.0 diff --git a/test/stores/config_store_test.dart b/test/stores/config_store_test.dart index c427e1c..736647c 100644 --- a/test/stores/config_store_test.dart +++ b/test/stores/config_store_test.dart @@ -19,6 +19,8 @@ const _lemmyUserSettings = LocalUserSettings( showBotAccounts: true, showNewPostNotifs: true, instanceHost: '', + emailVerified: true, + acceptedApplication: true, ); void main() {