From fff597b1f38fadbcc9085d70fc4787f2b72f64cd Mon Sep 17 00:00:00 2001 From: poppingmoon <63451158+poppingmoon@users.noreply.github.com> Date: Sun, 15 Oct 2023 17:31:37 +0900 Subject: [PATCH] =?UTF-8?q?shiosyakeyakini-info/misskey=5Fdart#25=20?= =?UTF-8?q?=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../users_show_response_extension.dart | 7 - lib/model/account.dart | 6 +- lib/model/account.freezed.dart | 24 +- lib/model/account.g.dart | 2 +- .../note_create_state_notifier.dart | 26 +- lib/view/common/avatar_icon.dart | 33 --- lib/view/common/common_drawer.dart | 2 +- .../misskey_notes/open_another_account.dart | 2 +- .../note_create_setting_top.dart | 4 +- .../account_settings_page/account_list.dart | 2 +- .../hard_mute_page/hard_mute_page.dart | 2 +- .../instance_mute_page.dart | 2 +- .../account_select_page.dart | 2 +- lib/view/user_page/user_control_dialog.dart | 23 +- lib/view/user_page/user_detail.dart | 233 ++++++++++-------- lib/view/user_page/user_page.dart | 8 +- .../users_list_detail_page.dart | 2 +- test/test_util/mock.mocks.dart | 163 +++++++----- test/test_util/test_datas.dart | 48 ++-- .../misskey_notes/misskey_notes_test.dart | 2 +- .../note_create_page_test.dart | 8 +- test/view/user_page/user_page_test.dart | 28 +-- 22 files changed, 325 insertions(+), 304 deletions(-) delete mode 100644 lib/extensions/users_show_response_extension.dart diff --git a/lib/extensions/users_show_response_extension.dart b/lib/extensions/users_show_response_extension.dart deleted file mode 100644 index 687db5449..000000000 --- a/lib/extensions/users_show_response_extension.dart +++ /dev/null @@ -1,7 +0,0 @@ -import 'package:misskey_dart/misskey_dart.dart'; - -extension UsersShowResponseExtension on UsersShowResponse { - String get acct { - return "@$username${host != null ? "@$host" : ""}"; - } -} diff --git a/lib/model/account.dart b/lib/model/account.dart index dea8b2747..98c472a84 100644 --- a/lib/model/account.dart +++ b/lib/model/account.dart @@ -13,7 +13,7 @@ class Account with _$Account { required String host, required String userId, String? token, - required IResponse i, + required MeDetailed i, }) = _Account; factory Account.fromJson(Map json) => @@ -41,7 +41,7 @@ class Account with _$Account { host: host, userId: "", token: null, - i: IResponse( + i: MeDetailed( id: "", username: "", createdAt: DateTime.now(), @@ -56,7 +56,7 @@ class Account with _$Account { followersCount: 0, notesCount: 0, publicReactions: false, - ffVisibility: "", + ffVisibility: FFVisibility.public, twoFactorEnabled: false, usePasswordLessLogin: false, securityKeys: false, diff --git a/lib/model/account.freezed.dart b/lib/model/account.freezed.dart index ed2914c05..5a8c0cbeb 100644 --- a/lib/model/account.freezed.dart +++ b/lib/model/account.freezed.dart @@ -23,7 +23,7 @@ mixin _$Account { String get host => throw _privateConstructorUsedError; String get userId => throw _privateConstructorUsedError; String? get token => throw _privateConstructorUsedError; - IResponse get i => throw _privateConstructorUsedError; + MeDetailed get i => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; @JsonKey(ignore: true) @@ -35,9 +35,9 @@ abstract class $AccountCopyWith<$Res> { factory $AccountCopyWith(Account value, $Res Function(Account) then) = _$AccountCopyWithImpl<$Res, Account>; @useResult - $Res call({String host, String userId, String? token, IResponse i}); + $Res call({String host, String userId, String? token, MeDetailed i}); - $IResponseCopyWith<$Res> get i; + $MeDetailedCopyWith<$Res> get i; } /// @nodoc @@ -74,14 +74,14 @@ class _$AccountCopyWithImpl<$Res, $Val extends Account> i: null == i ? _value.i : i // ignore: cast_nullable_to_non_nullable - as IResponse, + as MeDetailed, ) as $Val); } @override @pragma('vm:prefer-inline') - $IResponseCopyWith<$Res> get i { - return $IResponseCopyWith<$Res>(_value.i, (value) { + $MeDetailedCopyWith<$Res> get i { + return $MeDetailedCopyWith<$Res>(_value.i, (value) { return _then(_value.copyWith(i: value) as $Val); }); } @@ -94,10 +94,10 @@ abstract class _$$AccountImplCopyWith<$Res> implements $AccountCopyWith<$Res> { __$$AccountImplCopyWithImpl<$Res>; @override @useResult - $Res call({String host, String userId, String? token, IResponse i}); + $Res call({String host, String userId, String? token, MeDetailed i}); @override - $IResponseCopyWith<$Res> get i; + $MeDetailedCopyWith<$Res> get i; } /// @nodoc @@ -132,7 +132,7 @@ class __$$AccountImplCopyWithImpl<$Res> i: null == i ? _value.i : i // ignore: cast_nullable_to_non_nullable - as IResponse, + as MeDetailed, )); } } @@ -154,7 +154,7 @@ class _$AccountImpl extends _Account { @override final String? token; @override - final IResponse i; + final MeDetailed i; @override String toString() { @@ -180,7 +180,7 @@ abstract class _Account extends Account { {required final String host, required final String userId, final String? token, - required final IResponse i}) = _$AccountImpl; + required final MeDetailed i}) = _$AccountImpl; const _Account._() : super._(); factory _Account.fromJson(Map json) = _$AccountImpl.fromJson; @@ -192,7 +192,7 @@ abstract class _Account extends Account { @override String? get token; @override - IResponse get i; + MeDetailed get i; @override @JsonKey(ignore: true) _$$AccountImplCopyWith<_$AccountImpl> get copyWith => diff --git a/lib/model/account.g.dart b/lib/model/account.g.dart index fac86496a..7e9213d1f 100644 --- a/lib/model/account.g.dart +++ b/lib/model/account.g.dart @@ -11,7 +11,7 @@ _$AccountImpl _$$AccountImplFromJson(Map json) => host: json['host'] as String, userId: json['userId'] as String, token: json['token'] as String?, - i: IResponse.fromJson(json['i'] as Map), + i: MeDetailed.fromJson(json['i'] as Map), ); Map _$$AccountImplToJson(_$AccountImpl instance) => diff --git a/lib/state_notifier/note_create_page/note_create_state_notifier.dart b/lib/state_notifier/note_create_page/note_create_state_notifier.dart index f04731706..a5949efa9 100644 --- a/lib/state_notifier/note_create_page/note_create_state_notifier.dart +++ b/lib/state_notifier/note_create_page/note_create_state_notifier.dart @@ -181,6 +181,14 @@ class NoteCreateNotifier extends StateNotifier { } final deletedNoteChannel = note.channel; + final replyTo = []; + if (note.mentions.isNotEmpty) { + replyTo.addAll( + await misskey.users + .showByIds(UsersShowByIdsRequest(userIds: note.mentions)), + ); + } + resultState = resultState.copyWith( noteVisibility: note.visibility, localOnly: note.localOnly, @@ -193,11 +201,7 @@ class NoteCreateNotifier extends StateNotifier { isCw: note.cw?.isNotEmpty == true, text: note.text ?? "", reactionAcceptance: note.reactionAcceptance, - replyTo: [ - for (final userId in note.mentions) - (await misskey.users.show(UsersShowRequest(userId: userId))) - .toUser() - ], + replyTo: replyTo.toList(), isVote: note.poll != null, isVoteMultiple: note.poll?.multiple ?? false, voteExpireType: note.poll?.expiresAt == null @@ -223,6 +227,14 @@ class NoteCreateNotifier extends StateNotifier { } if (reply != null) { + final replyTo = []; + if (reply.mentions.isNotEmpty) { + replyTo.addAll( + await misskey.users + .showByIds(UsersShowByIdsRequest(userIds: reply.mentions)), + ); + } + resultState = resultState.copyWith( reply: reply, noteVisibility: @@ -231,9 +243,7 @@ class NoteCreateNotifier extends StateNotifier { isCw: reply.cw?.isNotEmpty == true, replyTo: [ reply.user, - for (final userId in reply.mentions) - (await misskey.users.show(UsersShowRequest(userId: userId))) - .toUser() + ...replyTo, ]..removeWhere((element) => element.id == state.account.i.id), ); } diff --git a/lib/view/common/avatar_icon.dart b/lib/view/common/avatar_icon.dart index 23bf5c21d..dda350e42 100644 --- a/lib/view/common/avatar_icon.dart +++ b/lib/view/common/avatar_icon.dart @@ -19,39 +19,6 @@ class AvatarIcon extends StatefulWidget { this.onTap, }); - factory AvatarIcon.fromIResponse(IResponse response, {double height = 48}) { - return AvatarIcon( - user: User( - id: response.id, - username: response.username, - avatarUrl: response.avatarUrl, - avatarBlurhash: response.avatarBlurhash, - avatarDecorations: response.avatarDecorations, - isCat: response.isCat, - isBot: response.isBot, - ), - height: height, - ); - } - - factory AvatarIcon.fromUserResponse( - UsersShowResponse response, { - double height = 48, - }) { - return AvatarIcon( - user: User( - id: response.id, - username: response.username, - avatarUrl: response.avatarUrl, - avatarBlurhash: response.avatarBlurhash, - avatarDecorations: response.avatarDecorations, - isCat: response.isCat, - isBot: response.isBot, - ), - height: height, - ); - } - @override State createState() => AvatarIconState(); } diff --git a/lib/view/common/common_drawer.dart b/lib/view/common/common_drawer.dart index eba70f9a1..8f244bd38 100644 --- a/lib/view/common/common_drawer.dart +++ b/lib/view/common/common_drawer.dart @@ -26,7 +26,7 @@ class CommonDrawer extends ConsumerWidget { AccountScope( account: account, child: ExpansionTile( - leading: AvatarIcon.fromIResponse(account.i), + leading: AvatarIcon(user: account.i), initiallyExpanded: account.acct == initialOpenAcct, title: SimpleMfmText( account.i.name ?? account.i.username, diff --git a/lib/view/common/misskey_notes/open_another_account.dart b/lib/view/common/misskey_notes/open_another_account.dart index 409273694..378c740a4 100644 --- a/lib/view/common/misskey_notes/open_another_account.dart +++ b/lib/view/common/misskey_notes/open_another_account.dart @@ -103,7 +103,7 @@ class AccountSelectDialog extends ConsumerWidget { AccountScope( account: account, child: ListTile( - leading: AvatarIcon.fromIResponse(account.i), + leading: AvatarIcon(user: account.i), title: SimpleMfmText(account.i.name ?? account.i.username, style: Theme.of(context).textTheme.titleMedium), subtitle: Text( diff --git a/lib/view/note_create_page/note_create_setting_top.dart b/lib/view/note_create_page/note_create_setting_top.dart index 518b78e5a..56595adf4 100644 --- a/lib/view/note_create_page/note_create_setting_top.dart +++ b/lib/view/note_create_page/note_create_setting_top.dart @@ -62,8 +62,8 @@ class NoteCreateSettingTop extends ConsumerWidget { return Row( children: [ const Padding(padding: EdgeInsets.only(left: 5)), - AvatarIcon.fromIResponse( - AccountScope.of(context).i, + AvatarIcon( + user: AccountScope.of(context).i, height: Theme.of(context).iconButtonTheme.style?.iconSize?.resolve({}) ?? 32, diff --git a/lib/view/settings_page/account_settings_page/account_list.dart b/lib/view/settings_page/account_settings_page/account_list.dart index 52effc461..6e1e3b0c4 100644 --- a/lib/view/settings_page/account_settings_page/account_list.dart +++ b/lib/view/settings_page/account_settings_page/account_list.dart @@ -82,7 +82,7 @@ class AccountListItem extends ConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { return ListTile( - leading: AvatarIcon.fromIResponse(account.i), + leading: AvatarIcon(user: account.i), title: Text( account.i.name ?? account.i.username, style: Theme.of(context).textTheme.titleMedium, diff --git a/lib/view/several_account_settings_page/hard_mute_page/hard_mute_page.dart b/lib/view/several_account_settings_page/hard_mute_page/hard_mute_page.dart index 82c44f402..18def7ca8 100644 --- a/lib/view/several_account_settings_page/hard_mute_page/hard_mute_page.dart +++ b/lib/view/several_account_settings_page/hard_mute_page/hard_mute_page.dart @@ -68,7 +68,7 @@ class HardMutePageState extends ConsumerState { body: SingleChildScrollView( child: Padding( padding: const EdgeInsets.all(10), - child: CommonFuture( + child: CommonFuture( future: ref.read(misskeyProvider(widget.account)).i.i(), futureFinished: (data) { controller.text = muteValueString(data.mutedWords); diff --git a/lib/view/several_account_settings_page/instance_mute_page/instance_mute_page.dart b/lib/view/several_account_settings_page/instance_mute_page/instance_mute_page.dart index 31c89ed1c..f879fb02a 100644 --- a/lib/view/several_account_settings_page/instance_mute_page/instance_mute_page.dart +++ b/lib/view/several_account_settings_page/instance_mute_page/instance_mute_page.dart @@ -48,7 +48,7 @@ class InstanceMutePageState extends ConsumerState { body: SingleChildScrollView( child: Padding( padding: const EdgeInsets.all(10), - child: CommonFuture( + child: CommonFuture( future: ref.read(misskeyProvider(widget.account)).i.i(), futureFinished: (data) { controller.text = data.mutedInstances.join("\n"); diff --git a/lib/view/sharing_account_select_page/account_select_page.dart b/lib/view/sharing_account_select_page/account_select_page.dart index 5fdabebf7..51e82ce3b 100644 --- a/lib/view/sharing_account_select_page/account_select_page.dart +++ b/lib/view/sharing_account_select_page/account_select_page.dart @@ -29,7 +29,7 @@ class SharingAccountSelectPage extends ConsumerWidget { initialMediaFiles: filePath, )); }, - leading: AvatarIcon.fromIResponse(account.i), + leading: AvatarIcon(user: account.i), title: Text(account.i.name ?? account.i.username, style: Theme.of(context).textTheme.titleMedium), subtitle: Text( diff --git a/lib/view/user_page/user_control_dialog.dart b/lib/view/user_page/user_control_dialog.dart index e0ffab0e2..28e049ea3 100644 --- a/lib/view/user_page/user_control_dialog.dart +++ b/lib/view/user_page/user_control_dialog.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:miria/extensions/users_show_response_extension.dart'; +import 'package:miria/extensions/user_extension.dart'; import 'package:miria/model/account.dart'; import 'package:miria/providers.dart'; import 'package:miria/view/common/error_dialog_handler.dart'; @@ -21,14 +21,12 @@ enum UserControl { class UserControlDialog extends ConsumerStatefulWidget { final Account account; - final UsersShowResponse response; - final bool isMe; + final UserDetailed response; const UserControlDialog({ super.key, required this.account, required this.response, - required this.isMe, }); @override @@ -138,6 +136,7 @@ class UserControlDialogState extends ConsumerState { @override Widget build(BuildContext context) { + final user = widget.response; return ListView(children: [ ListTile( onTap: () { @@ -146,7 +145,7 @@ class UserControlDialogState extends ConsumerState { text: Uri( scheme: "https", host: widget.account.host, - path: widget.response.acct, + path: user.acct, ).toString(), ), ); @@ -161,7 +160,7 @@ class UserControlDialogState extends ConsumerState { onTap: () { Clipboard.setData( ClipboardData( - text: widget.response.name ?? widget.response.username, + text: user.name ?? user.username, ), ); ScaffoldMessenger.of(context).showSnackBar( @@ -173,7 +172,7 @@ class UserControlDialogState extends ConsumerState { ), ListTile( onTap: () { - Clipboard.setData(ClipboardData(text: widget.response.acct)); + Clipboard.setData(ClipboardData(text: user.acct)); ScaffoldMessenger.of(context).showSnackBar( const SnackBar(content: Text("コピーしました")), ); @@ -188,7 +187,7 @@ class UserControlDialogState extends ConsumerState { Uri( scheme: "https", host: widget.account.host, - path: widget.response.acct, + path: user.acct, ), ); Navigator.of(context).pop(); @@ -202,8 +201,8 @@ class UserControlDialogState extends ConsumerState { onTap: addToAntenna, title: const Text("アンテナに追加"), ), - if (!widget.isMe) ...[ - if (widget.response.isRenoteMuted ?? false) + if (user is UserDetailedNotMeWithRelations) ...[ + if (user.isRenoteMuted) ListTile( onTap: renoteMuteDelete.expectFailure(context), title: const Text("Renoteのミュート解除する"), @@ -213,7 +212,7 @@ class UserControlDialogState extends ConsumerState { onTap: renoteMuteCreate.expectFailure(context), title: const Text("Renoteをミュートする"), ), - if (widget.response.isMuted ?? false) + if (user.isMuted) ListTile( onTap: muteDelete.expectFailure(context), title: const Text("ミュート解除する"), @@ -223,7 +222,7 @@ class UserControlDialogState extends ConsumerState { onTap: muteCreate.expectFailure(context), title: const Text("ミュートする"), ), - if (widget.response.isBlocking ?? false) + if (user.isBlocking) ListTile( onTap: blockingDelete.expectFailure(context), title: const Text("ブロックを解除する"), diff --git a/lib/view/user_page/user_detail.dart b/lib/view/user_page/user_detail.dart index 858602e51..79adeda74 100644 --- a/lib/view/user_page/user_detail.dart +++ b/lib/view/user_page/user_detail.dart @@ -3,6 +3,7 @@ import 'package:confetti/confetti.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:miria/extensions/date_time_extension.dart'; +import 'package:miria/extensions/user_extension.dart'; import 'package:miria/model/account.dart'; import 'package:miria/providers.dart'; import 'package:miria/router/app_router.dart'; @@ -21,7 +22,7 @@ import 'package:misskey_dart/misskey_dart.dart'; class UserDetail extends ConsumerStatefulWidget { final Account account; final Account? controlAccount; - final UsersShowResponse response; + final UserDetailed response; const UserDetail({ super.key, @@ -35,12 +36,18 @@ class UserDetail extends ConsumerStatefulWidget { } class UserDetailState extends ConsumerState { - late UsersShowResponse response; + late UserDetailed response; bool isFollowEditing = false; String memo = ""; Future followCreate() async { if (isFollowEditing) return; + + final user = response; + if (user is! UserDetailedNotMeWithRelations) { + return; + } + setState(() { isFollowEditing = true; }); @@ -48,13 +55,14 @@ class UserDetailState extends ConsumerState { await ref .read(misskeyProvider(AccountScope.of(context))) .following - .create(FollowingCreateRequest(userId: response.id)); + .create(FollowingCreateRequest(userId: user.id)); if (!mounted) return; + final requiresFollowRequest = user.isLocked && !user.isFollowed; setState(() { isFollowEditing = false; - response = response.copyWith( - isFollowing: !response.requiresFollowRequest, - hasPendingFollowRequestFromYou: response.requiresFollowRequest, + response = user.copyWith( + isFollowing: !requiresFollowRequest, + hasPendingFollowRequestFromYou: requiresFollowRequest, ); }); } catch (e) { @@ -68,6 +76,12 @@ class UserDetailState extends ConsumerState { Future followDelete() async { if (isFollowEditing) return; + + final user = response; + if (user is! UserDetailedNotMeWithRelations) { + return; + } + final account = AccountScope.of(context); if (await SimpleConfirmDialog.show( context: context, @@ -84,11 +98,11 @@ class UserDetailState extends ConsumerState { await ref .read(misskeyProvider(account)) .following - .delete(FollowingDeleteRequest(userId: response.id)); + .delete(FollowingDeleteRequest(userId: user.id)); if (!mounted) return; setState(() { isFollowEditing = false; - response = response.copyWith(isFollowing: false); + response = user.copyWith(isFollowing: false); }); } catch (e) { if (!mounted) return; @@ -101,6 +115,12 @@ class UserDetailState extends ConsumerState { Future followRequestCancel() async { if (isFollowEditing) return; + + final user = response; + if (user is! UserDetailedNotMeWithRelations) { + return; + } + setState(() { isFollowEditing = true; }); @@ -109,11 +129,11 @@ class UserDetailState extends ConsumerState { .read(misskeyProvider(AccountScope.of(context))) .following .requests - .cancel(FollowingRequestsCancelRequest(userId: response.id)); + .cancel(FollowingRequestsCancelRequest(userId: user.id)); if (!mounted) return; setState(() { isFollowEditing = false; - response = response.copyWith(hasPendingFollowRequestFromYou: false); + response = user.copyWith(hasPendingFollowRequestFromYou: false); }); } catch (e) { if (!mounted) return; @@ -124,45 +144,50 @@ class UserDetailState extends ConsumerState { } } - Future userControl(bool isMe) async { + Future userControl() async { final result = await showModalBottomSheet( - context: context, - builder: (context) => UserControlDialog( - account: widget.account, - response: response, - isMe: isMe, - )); + context: context, + builder: (context) => UserControlDialog( + account: widget.account, + response: response, + ), + ); if (result == null) return; + final user = response; + if (user is! UserDetailedNotMeWithRelations) { + return; + } + switch (result) { case UserControl.createMute: setState(() { - response = response.copyWith(isMuted: true); + response = user.copyWith(isMuted: true); }); break; case UserControl.deleteMute: setState(() { - response = response.copyWith(isMuted: false); + response = user.copyWith(isMuted: false); }); break; case UserControl.createRenoteMute: setState(() { - response = response.copyWith(isRenoteMuted: true); + response = user.copyWith(isRenoteMuted: true); }); break; case UserControl.deleteRenoteMute: setState(() { - response = response.copyWith(isRenoteMuted: false); + response = user.copyWith(isRenoteMuted: false); }); break; case UserControl.createBlock: setState(() { - response = response.copyWith(isBlocking: true); + response = user.copyWith(isBlocking: true); }); break; case UserControl.deleteBlock: setState(() { - response = response.copyWith(isBlocking: false); + response = user.copyWith(isBlocking: false); }); break; } @@ -176,10 +201,7 @@ class UserDetailState extends ConsumerState { } Widget buildContent() { - final userName = - "${response.username}${response.host != null ? "@${response.host ?? ""}" : ""}"; - final isMe = (widget.response.host == null && - widget.response.username == AccountScope.of(context).userId); + final user = response; return Column(children: [ if (widget.controlAccount == null) @@ -189,9 +211,7 @@ class UserDetailState extends ConsumerState { mainAxisSize: MainAxisSize.max, crossAxisAlignment: CrossAxisAlignment.start, children: [ - if (isMe) - const Spacer() - else + if (user is UserDetailedNotMeWithRelations) Expanded( child: Align( alignment: Alignment.centerRight, @@ -200,86 +220,92 @@ class UserDetailState extends ConsumerState { child: Wrap( crossAxisAlignment: WrapCrossAlignment.center, children: [ - if (response.isRenoteMuted ?? false) + if (user.isRenoteMuted) const Card( - child: Padding( - padding: EdgeInsets.all(10), - child: Text("Renoteのミュート中"), - )), - if (response.isMuted ?? false) + child: Padding( + padding: EdgeInsets.all(10), + child: Text("Renoteのミュート中"), + ), + ), + if (user.isMuted) const Card( - child: Padding( - padding: EdgeInsets.all(10), - child: Text("ミュート中"), - )), - if (response.isBlocking ?? false) + child: Padding( + padding: EdgeInsets.all(10), + child: Text("ミュート中"), + ), + ), + if (user.isBlocking) const Card( - child: Padding( - padding: EdgeInsets.all(10), - child: Text("ブロック中"), - )), - if ((response.isFollowed ?? false)) + child: Padding( + padding: EdgeInsets.all(10), + child: Text("ブロック中"), + ), + ), + if (user.isFollowed) const Padding( padding: EdgeInsets.only(right: 8.0), child: Card( - child: Padding( - padding: EdgeInsets.all(10), - child: Text("フォローされています"), - )), + child: Padding( + padding: EdgeInsets.all(10), + child: Text("フォローされています"), + ), + ), ), if (!isFollowEditing) - (response.isFollowing ?? false) - ? ElevatedButton( - onPressed: - followDelete.expectFailure(context), - child: const Text("フォロー解除"), - ) - : (response.hasPendingFollowRequestFromYou ?? - false) - ? ElevatedButton( - onPressed: followRequestCancel - .expectFailure(context), - child: const Text("フォロー許可待ち"), - ) - : OutlinedButton( - onPressed: followCreate - .expectFailure(context), - child: Text( - (response.requiresFollowRequest) - ? "フォロー申請" - : "フォローする", - ), - ) + if (user.isFollowing) + ElevatedButton( + onPressed: + followDelete.expectFailure(context), + child: const Text("フォロー解除"), + ) + else if (user.hasPendingFollowRequestFromYou) + ElevatedButton( + onPressed: followRequestCancel + .expectFailure(context), + child: const Text("フォロー許可待ち"), + ) + else + OutlinedButton( + onPressed: + followCreate.expectFailure(context), + child: Text( + user.isLocked ? "フォロー申請" : "フォローする", + ), + ) else Align( alignment: Alignment.centerRight, child: TextButton.icon( - onPressed: () {}, - icon: SizedBox( - width: Theme.of(context) - .textTheme - .bodyMedium - ?.fontSize ?? - 22, - height: Theme.of(context) - .textTheme - .bodyMedium - ?.fontSize ?? - 22, - child: - const CircularProgressIndicator()), - label: const Text("更新中")), + onPressed: () {}, + icon: SizedBox( + width: Theme.of(context) + .textTheme + .bodyMedium + ?.fontSize ?? + 22, + height: Theme.of(context) + .textTheme + .bodyMedium + ?.fontSize ?? + 22, + child: const CircularProgressIndicator(), + ), + label: const Text("更新中"), + ), ), ], ), ), ), - ), + ) + else + const Spacer(), Align( alignment: Alignment.center, child: IconButton( - onPressed: () => userControl(isMe), - icon: const Icon(Icons.more_vert)), + onPressed: userControl, + icon: const Icon(Icons.more_vert), + ), ) ], )), @@ -289,8 +315,8 @@ class UserDetailState extends ConsumerState { child: Column(children: [ Row( children: [ - AvatarIcon.fromUserResponse( - response, + AvatarIcon( + user: response, height: 80, ), Expanded( @@ -304,16 +330,16 @@ class UserDetailState extends ConsumerState { MfmText( mfmText: response.name ?? response.username, style: Theme.of(context).textTheme.headlineSmall, - emoji: response.emojis ?? {}, + emoji: response.emojis, ), Text( - "@$userName", + response.acct, style: Theme.of(context).textTheme.bodyLarge, - ) + ), ], ), ), - ) + ), ], ), const Padding(padding: EdgeInsets.only(top: 5)), @@ -399,7 +425,7 @@ class UserDetailState extends ConsumerState { alignment: Alignment.center, child: MfmText( mfmText: response.description ?? "", - emoji: response.emojis ?? {}, + emoji: response.emojis, ), ), const Padding(padding: EdgeInsets.only(top: 20)), @@ -450,13 +476,13 @@ class UserDetailState extends ConsumerState { TableCell( child: MfmText( mfmText: field.name, - emoji: response.emojis ?? {}, + emoji: response.emojis, ), ), TableCell( child: MfmText( mfmText: field.value, - emoji: response.emojis ?? {}, + emoji: response.emojis, )), ]) ], @@ -545,7 +571,7 @@ class UserDetailState extends ConsumerState { } class BirthdayConfetti extends StatefulWidget { - final UsersShowResponse response; + final UserDetailed response; final Widget child; const BirthdayConfetti({ @@ -589,10 +615,3 @@ class BirthdayConfettiState extends State { return widget.child; } } - -extension on UsersShowResponse { - bool get requiresFollowRequest { - return isLocked && - !((isFollowed ?? false) && (autoAcceptFollowed ?? false)); - } -} diff --git a/lib/view/user_page/user_page.dart b/lib/view/user_page/user_page.dart index 8e50808b6..d7271228f 100644 --- a/lib/view/user_page/user_page.dart +++ b/lib/view/user_page/user_page.dart @@ -16,9 +16,9 @@ import 'package:misskey_dart/misskey_dart.dart'; class UserInfo { final String userId; - final UsersShowResponse? response; + final UserDetailed? response; final String? remoteUserId; - final UsersShowResponse? remoteResponse; + final UserDetailed? remoteResponse; const UserInfo({ required this.userId, @@ -180,8 +180,8 @@ class UserDetailTab extends ConsumerStatefulWidget { } class UserDetailTabState extends ConsumerState { - UsersShowResponse? response; - UsersShowResponse? remoteResponse; + UserDetailed? response; + UserDetailed? remoteResponse; (Object?, StackTrace)? error; @override diff --git a/lib/view/users_list_page/users_list_detail_page.dart b/lib/view/users_list_page/users_list_detail_page.dart index c0034225f..152ad6895 100644 --- a/lib/view/users_list_page/users_list_detail_page.dart +++ b/lib/view/users_list_page/users_list_detail_page.dart @@ -66,7 +66,7 @@ class _UsersListUsers userIds: list.userIds, ), ); - return response.map((e) => e.toUser()).toList(); + return response.toList(); } Misskey get _misskey => arg.$1; diff --git a/test/test_util/mock.mocks.dart b/test/test_util/mock.mocks.dart index 50d821a43..c512c3605 100644 --- a/test/test_util/mock.mocks.dart +++ b/test/test_util/mock.mocks.dart @@ -475,8 +475,8 @@ class _FakeMisskeyFollowingRequests_39 extends _i1.SmartFake ); } -class _FakeUser_40 extends _i1.SmartFake implements _i5.User { - _FakeUser_40( +class _FakeUserLite_40 extends _i1.SmartFake implements _i5.UserLite { + _FakeUserLite_40( Object parent, Invocation parentInvocation, ) : super( @@ -495,8 +495,8 @@ class _FakeHashtag_41 extends _i1.SmartFake implements _i5.Hashtag { ); } -class _FakeIResponse_42 extends _i1.SmartFake implements _i5.IResponse { - _FakeIResponse_42( +class _FakeMeDetailed_42 extends _i1.SmartFake implements _i5.MeDetailed { + _FakeMeDetailed_42( Object parent, Invocation parentInvocation, ) : super( @@ -592,9 +592,8 @@ class _FakeMisskeyUsersLists_50 extends _i1.SmartFake ); } -class _FakeUsersShowResponse_51 extends _i1.SmartFake - implements _i5.UsersShowResponse { - _FakeUsersShowResponse_51( +class _FakeUserDetailed_51 extends _i1.SmartFake implements _i5.UserDetailed { + _FakeUserDetailed_51( Object parent, Invocation parentInvocation, ) : super( @@ -1239,6 +1238,23 @@ class MockAccountRepository extends _i1.Mock implements _i24.AccountRepository { returnValueForMissingStub: _i16.Future.value(), ) as _i16.Future); + @override + _i16.Future reorder( + int? oldIndex, + int? newIndex, + ) => + (super.noSuchMethod( + Invocation.method( + #reorder, + [ + oldIndex, + newIndex, + ], + ), + returnValue: _i16.Future.value(), + returnValueForMissingStub: _i16.Future.value(), + ) as _i16.Future); + @override bool updateShouldNotify( List<_i17.Account>? previous, @@ -2048,15 +2064,16 @@ class MockMisskey extends _i1.Mock implements _i5.Misskey { ) as _i16.Future>); @override - _i16.Future> pinnedUsers() => (super.noSuchMethod( + _i16.Future> pinnedUsers() => (super.noSuchMethod( Invocation.method( #pinnedUsers, [], ), - returnValue: _i16.Future>.value(<_i5.User>[]), + returnValue: + _i16.Future>.value(<_i5.UserDetailed>[]), returnValueForMissingStub: - _i16.Future>.value(<_i5.User>[]), - ) as _i16.Future>); + _i16.Future>.value(<_i5.UserDetailed>[]), + ) as _i16.Future>); @override _i5.SocketController homeTimelineStream({ @@ -2370,6 +2387,10 @@ class MockMisskey extends _i1.Mock implements _i5.Misskey { String, _i5.TimelineVoted, )? onVoted, + _i16.FutureOr Function( + String, + _i5.NoteEdited, + )? onUpdated, }) => (super.noSuchMethod( Invocation.method( @@ -2382,6 +2403,7 @@ class MockMisskey extends _i1.Mock implements _i5.Misskey { #onUnreacted: onUnreacted, #onDeleted: onDeleted, #onVoted: onVoted, + #onUpdated: onUpdated, }, ), returnValue: _FakeSocketController_30( @@ -2396,6 +2418,7 @@ class MockMisskey extends _i1.Mock implements _i5.Misskey { #onUnreacted: onUnreacted, #onDeleted: onDeleted, #onVoted: onVoted, + #onUpdated: onUpdated, }, ), ), @@ -2411,6 +2434,7 @@ class MockMisskey extends _i1.Mock implements _i5.Misskey { #onUnreacted: onUnreacted, #onDeleted: onDeleted, #onVoted: onVoted, + #onUpdated: onUpdated, }, ), ), @@ -2493,8 +2517,8 @@ class MockMisskey extends _i1.Mock implements _i5.Misskey { _i5.SocketController userListStream({ required String? listId, _i16.FutureOr Function(_i5.Note)? onNoteReceived, - _i16.FutureOr Function(_i5.User)? onUserAdded, - _i16.FutureOr Function(_i5.User)? onUserRemoved, + _i16.FutureOr Function(_i5.UserLite)? onUserAdded, + _i16.FutureOr Function(_i5.UserLite)? onUserRemoved, _i16.FutureOr Function( String, _i5.TimelineReacted, @@ -2722,10 +2746,10 @@ class MockMisskey extends _i1.Mock implements _i5.Misskey { _i16.FutureOr Function(_i5.Note)? onMention, _i16.FutureOr Function(_i5.Note)? onReply, _i16.FutureOr Function(_i5.Note)? onRenote, - _i16.FutureOr Function(_i5.User)? onFollow, - _i16.FutureOr Function(_i5.User)? onFollowed, - _i16.FutureOr Function(_i5.User)? onUnfollow, - _i16.FutureOr Function(_i5.User)? onMeUpdated, + _i16.FutureOr Function(_i5.UserDetailedNotMe)? onFollow, + _i16.FutureOr Function(_i5.UserLite)? onFollowed, + _i16.FutureOr Function(_i5.UserDetailedNotMe)? onUnfollow, + _i16.FutureOr Function(_i5.MeDetailed)? onMeUpdated, _i16.FutureOr Function()? onReadAllNotifications, _i16.FutureOr Function(_i5.INotificationsResponse)? onUnreadNotification, @@ -2733,7 +2757,7 @@ class MockMisskey extends _i1.Mock implements _i5.Misskey { _i16.FutureOr Function()? onReadAllUnreadMentions, _i16.FutureOr Function(String)? onUnreadSpecifiedNote, _i16.FutureOr Function()? onReadAllUnreadSpecifiedNotes, - _i16.FutureOr Function(_i5.User)? onReceiveFollowRequest, + _i16.FutureOr Function(_i5.UserLite)? onReceiveFollowRequest, _i16.FutureOr Function()? onReadAllAnnouncements, }) => (super.noSuchMethod( @@ -3571,16 +3595,18 @@ class MockMisskeyFederation extends _i1.Mock implements _i5.MisskeyFederation { ) as _i16.Future<_i5.FederationShowInstanceResponse>); @override - _i16.Future> users(_i5.FederationUsersRequest? request) => + _i16.Future> users( + _i5.FederationUsersRequest? request) => (super.noSuchMethod( Invocation.method( #users, [request], ), - returnValue: _i16.Future>.value(<_i5.User>[]), + returnValue: + _i16.Future>.value(<_i5.UserDetailed>[]), returnValueForMissingStub: - _i16.Future>.value(<_i5.User>[]), - ) as _i16.Future>); + _i16.Future>.value(<_i5.UserDetailed>[]), + ) as _i16.Future>); } /// A class which mocks [MisskeyFollowing]. @@ -3601,73 +3627,77 @@ class MockMisskeyFollowing extends _i1.Mock implements _i5.MisskeyFollowing { ) as _i5.MisskeyFollowingRequests); @override - _i16.Future<_i5.User> create(_i5.FollowingCreateRequest? request) => + _i16.Future<_i5.UserLite> create(_i5.FollowingCreateRequest? request) => (super.noSuchMethod( Invocation.method( #create, [request], ), - returnValue: _i16.Future<_i5.User>.value(_FakeUser_40( + returnValue: _i16.Future<_i5.UserLite>.value(_FakeUserLite_40( this, Invocation.method( #create, [request], ), )), - returnValueForMissingStub: _i16.Future<_i5.User>.value(_FakeUser_40( + returnValueForMissingStub: + _i16.Future<_i5.UserLite>.value(_FakeUserLite_40( this, Invocation.method( #create, [request], ), )), - ) as _i16.Future<_i5.User>); + ) as _i16.Future<_i5.UserLite>); @override - _i16.Future<_i5.User> delete(_i5.FollowingDeleteRequest? request) => + _i16.Future<_i5.UserLite> delete(_i5.FollowingDeleteRequest? request) => (super.noSuchMethod( Invocation.method( #delete, [request], ), - returnValue: _i16.Future<_i5.User>.value(_FakeUser_40( + returnValue: _i16.Future<_i5.UserLite>.value(_FakeUserLite_40( this, Invocation.method( #delete, [request], ), )), - returnValueForMissingStub: _i16.Future<_i5.User>.value(_FakeUser_40( + returnValueForMissingStub: + _i16.Future<_i5.UserLite>.value(_FakeUserLite_40( this, Invocation.method( #delete, [request], ), )), - ) as _i16.Future<_i5.User>); + ) as _i16.Future<_i5.UserLite>); @override - _i16.Future<_i5.User> invalidate(_i5.FollowingInvalidateRequest? request) => + _i16.Future<_i5.UserLite> invalidate( + _i5.FollowingInvalidateRequest? request) => (super.noSuchMethod( Invocation.method( #invalidate, [request], ), - returnValue: _i16.Future<_i5.User>.value(_FakeUser_40( + returnValue: _i16.Future<_i5.UserLite>.value(_FakeUserLite_40( this, Invocation.method( #invalidate, [request], ), )), - returnValueForMissingStub: _i16.Future<_i5.User>.value(_FakeUser_40( + returnValueForMissingStub: + _i16.Future<_i5.UserLite>.value(_FakeUserLite_40( this, Invocation.method( #invalidate, [request], ), )), - ) as _i16.Future<_i5.User>); + ) as _i16.Future<_i5.UserLite>); @override _i16.Future updateAll(_i5.FollowingUpdateAllRequest? request) => @@ -3748,16 +3778,18 @@ class MockMisskeyHashtags extends _i1.Mock implements _i5.MisskeyHashtags { ) as _i16.Future>); @override - _i16.Future> users(_i5.HashtagsUsersRequest? request) => + _i16.Future> users( + _i5.HashtagsUsersRequest? request) => (super.noSuchMethod( Invocation.method( #users, [request], ), - returnValue: _i16.Future>.value(<_i5.User>[]), + returnValue: + _i16.Future>.value(<_i5.UserDetailed>[]), returnValueForMissingStub: - _i16.Future>.value(<_i5.User>[]), - ) as _i16.Future>); + _i16.Future>.value(<_i5.UserDetailed>[]), + ) as _i16.Future>); } /// A class which mocks [MisskeyI]. @@ -3765,12 +3797,12 @@ class MockMisskeyHashtags extends _i1.Mock implements _i5.MisskeyHashtags { /// See the documentation for Mockito's code generation for more information. class MockMisskeyI extends _i1.Mock implements _i5.MisskeyI { @override - _i16.Future<_i5.IResponse> i() => (super.noSuchMethod( + _i16.Future<_i5.MeDetailed> i() => (super.noSuchMethod( Invocation.method( #i, [], ), - returnValue: _i16.Future<_i5.IResponse>.value(_FakeIResponse_42( + returnValue: _i16.Future<_i5.MeDetailed>.value(_FakeMeDetailed_42( this, Invocation.method( #i, @@ -3778,14 +3810,14 @@ class MockMisskeyI extends _i1.Mock implements _i5.MisskeyI { ), )), returnValueForMissingStub: - _i16.Future<_i5.IResponse>.value(_FakeIResponse_42( + _i16.Future<_i5.MeDetailed>.value(_FakeMeDetailed_42( this, Invocation.method( #i, [], ), )), - ) as _i16.Future<_i5.IResponse>); + ) as _i16.Future<_i5.MeDetailed>); @override _i16.Future> notifications( @@ -3829,13 +3861,13 @@ class MockMisskeyI extends _i1.Mock implements _i5.MisskeyI { ) as _i16.Future>); @override - _i16.Future<_i5.IResponse> update(_i5.IUpdateRequest? request) => + _i16.Future<_i5.MeDetailed> update(_i5.IUpdateRequest? request) => (super.noSuchMethod( Invocation.method( #update, [request], ), - returnValue: _i16.Future<_i5.IResponse>.value(_FakeIResponse_42( + returnValue: _i16.Future<_i5.MeDetailed>.value(_FakeMeDetailed_42( this, Invocation.method( #update, @@ -3843,14 +3875,14 @@ class MockMisskeyI extends _i1.Mock implements _i5.MisskeyI { ), )), returnValueForMissingStub: - _i16.Future<_i5.IResponse>.value(_FakeIResponse_42( + _i16.Future<_i5.MeDetailed>.value(_FakeMeDetailed_42( this, Invocation.method( #update, [request], ), )), - ) as _i16.Future<_i5.IResponse>); + ) as _i16.Future<_i5.MeDetailed>); } /// A class which mocks [MisskeyNotes]. @@ -4404,14 +4436,13 @@ class MockMisskeyUsers extends _i1.Mock implements _i5.MisskeyUsers { ) as _i5.MisskeyUsersLists); @override - _i16.Future<_i5.UsersShowResponse> show(_i5.UsersShowRequest? request) => + _i16.Future<_i5.UserDetailed> show(_i5.UsersShowRequest? request) => (super.noSuchMethod( Invocation.method( #show, [request], ), - returnValue: - _i16.Future<_i5.UsersShowResponse>.value(_FakeUsersShowResponse_51( + returnValue: _i16.Future<_i5.UserDetailed>.value(_FakeUserDetailed_51( this, Invocation.method( #show, @@ -4419,40 +4450,38 @@ class MockMisskeyUsers extends _i1.Mock implements _i5.MisskeyUsers { ), )), returnValueForMissingStub: - _i16.Future<_i5.UsersShowResponse>.value(_FakeUsersShowResponse_51( + _i16.Future<_i5.UserDetailed>.value(_FakeUserDetailed_51( this, Invocation.method( #show, [request], ), )), - ) as _i16.Future<_i5.UsersShowResponse>); + ) as _i16.Future<_i5.UserDetailed>); @override - _i16.Future> showByIds( + _i16.Future> showByIds( _i5.UsersShowByIdsRequest? request) => (super.noSuchMethod( Invocation.method( #showByIds, [request], ), - returnValue: _i16.Future>.value( - <_i5.UsersShowResponse>[]), + returnValue: + _i16.Future>.value(<_i5.UserDetailed>[]), returnValueForMissingStub: - _i16.Future>.value( - <_i5.UsersShowResponse>[]), - ) as _i16.Future>); + _i16.Future>.value(<_i5.UserDetailed>[]), + ) as _i16.Future>); @override - _i16.Future<_i5.UsersShowResponse> showByName( + _i16.Future<_i5.UserDetailed> showByName( _i5.UsersShowByUserNameRequest? request) => (super.noSuchMethod( Invocation.method( #showByName, [request], ), - returnValue: - _i16.Future<_i5.UsersShowResponse>.value(_FakeUsersShowResponse_51( + returnValue: _i16.Future<_i5.UserDetailed>.value(_FakeUserDetailed_51( this, Invocation.method( #showByName, @@ -4460,14 +4489,14 @@ class MockMisskeyUsers extends _i1.Mock implements _i5.MisskeyUsers { ), )), returnValueForMissingStub: - _i16.Future<_i5.UsersShowResponse>.value(_FakeUsersShowResponse_51( + _i16.Future<_i5.UserDetailed>.value(_FakeUserDetailed_51( this, Invocation.method( #showByName, [request], ), )), - ) as _i16.Future<_i5.UsersShowResponse>); + ) as _i16.Future<_i5.UserDetailed>); @override _i16.Future> notes(_i5.UsersNotesRequest? request) => @@ -4573,16 +4602,18 @@ class MockMisskeyUsers extends _i1.Mock implements _i5.MisskeyUsers { ) as _i16.Future>); @override - _i16.Future> users(_i5.UsersUsersRequest? request) => + _i16.Future> users( + _i5.UsersUsersRequest? request) => (super.noSuchMethod( Invocation.method( #users, [request], ), - returnValue: _i16.Future>.value(<_i5.User>[]), + returnValue: + _i16.Future>.value(<_i5.UserDetailed>[]), returnValueForMissingStub: - _i16.Future>.value(<_i5.User>[]), - ) as _i16.Future>); + _i16.Future>.value(<_i5.UserDetailed>[]), + ) as _i16.Future>); @override _i16.Future updateMemo(_i5.UsersUpdateMemoRequest? request) => diff --git a/test/test_util/test_datas.dart b/test/test_util/test_datas.dart index c53826662..30fb45a87 100644 --- a/test/test_util/test_datas.dart +++ b/test/test_util/test_datas.dart @@ -11,7 +11,7 @@ class TestData { Account(host: "example.miria.shiosyakeyakini.info", userId: "ai", i: i1); // i - static IResponse i1 = IResponse.fromJson(JSON5.parse(r""" + static MeDetailed i1 = MeDetailed.fromJson(JSON5.parse(r""" { id: '7rkr3b1c1c', name: '藍', @@ -376,8 +376,8 @@ class TestData { files: [], replyId: null, renoteId: null, -} - +} + ''')); static Note note2 = Note.fromJson(JSON5.parse(r''' @@ -415,7 +415,7 @@ class TestData { files: [], replyId: null, renoteId: null, -} +} ''')); /// 自身でないノート1 @@ -460,7 +460,7 @@ class TestData { files: [], replyId: null, renoteId: null, -} +} ''')); /// 自身のノート(投票込みのノート) @@ -641,7 +641,7 @@ class TestData { replyId: null, renoteId: null, myReaction: ':ultra_igyo@.:', -} +} ''')); /// Renote @@ -776,7 +776,7 @@ class TestData { folder: null, userId: null, user: null, - } + } ''')); static DriveFile drive2AsVideo = DriveFile.fromJson(JSON5.parse(r''' @@ -809,7 +809,7 @@ class TestData { data: await binaryImage); // ユーザー情報 - static User user1 = User.fromJson(JSON5.parse(r''' + static UserLite user1 = UserLite.fromJson(JSON5.parse(r''' { id: '7rkr3b1c1c', name: '藍', @@ -825,7 +825,8 @@ class TestData { }''')); static String user1ExpectId = "7rkr3b1c1c"; - static User detailedUser1 = User.fromJson(JSON5.parse(r''' + static UserDetailedNotMeWithRelations detailedUser1 = + UserDetailedNotMeWithRelations.fromJson(JSON5.parse(r''' { id: '7z9zua5kyv', name: 'おいしいBot', @@ -994,7 +995,8 @@ class TestData { isRenoteMuted: false, } ''')); - static User detailedUser2 = User.fromJson(JSON5.parse(r''' + static UserDetailedNotMeWithRelations detailedUser2 = + UserDetailedNotMeWithRelations.fromJson(JSON5.parse(r''' { id: '9gbzuv2cze', name: '藍ちゃんにおじさん構文でメンションを送るbot', @@ -1106,8 +1108,8 @@ class TestData { static String detailedUser2ExpectedId = "9gbzuv2cze"; // ユーザー情報 - static UsersShowResponse usersShowResponse1 = - UsersShowResponse.fromJson(JSON5.parse(r''' + static UserDetailedNotMeWithRelations usersShowResponse1 = + UserDetailedNotMeWithRelations.fromJson(JSON5.parse(r''' { id: '7rkr3b1c1c', name: '藍', @@ -1214,12 +1216,12 @@ class TestData { isBlocked: false, isMuted: false, isRenoteMuted: false, -} - +} + ''')); - static UsersShowResponse usersShowResponse2 = - UsersShowResponse.fromJson(JSON5.parse(r''' + static UserDetailedNotMeWithRelations usersShowResponse2 = + UserDetailedNotMeWithRelations.fromJson(JSON5.parse(r''' { id: '7z9zua5kyv', name: 'おいしいBot', @@ -1388,12 +1390,12 @@ class TestData { isBlocked: false, isMuted: false, isRenoteMuted: false, -} - +} + ''')); - static UsersShowResponse usersShowResponse3AsRemoteUser = - UsersShowResponse.fromJson(JSON5.parse(r''' + static UserDetailedNotMeWithRelations usersShowResponse3AsRemoteUser = + UserDetailedNotMeWithRelations.fromJson(JSON5.parse(r''' { id: '9i08deo0vj', name: 'あけおめらんか~', @@ -1473,8 +1475,8 @@ class TestData { } ''')); - static UsersShowResponse usersShowResponse3AsLocalUser = - UsersShowResponse.fromJson(JSON5.parse(''' + static UserDetailedNotMeWithRelations usersShowResponse3AsLocalUser = + UserDetailedNotMeWithRelations.fromJson(JSON5.parse(''' { id: '9i07ia9bf0', name: 'あけおめらんか~', @@ -1673,7 +1675,7 @@ class TestData { isFollowing: true, isFavorited: true, hasUnreadNote: false, -} +} ''')); // アンテナ diff --git a/test/view/common/misskey_notes/misskey_notes_test.dart b/test/view/common/misskey_notes/misskey_notes_test.dart index 5da4e8d60..8fd0a45f0 100644 --- a/test/view/common/misskey_notes/misskey_notes_test.dart +++ b/test/view/common/misskey_notes/misskey_notes_test.dart @@ -257,7 +257,7 @@ System.out.println("@ai uneune"); NotesReactionsResponse( id: "reaction1", createdAt: DateTime.now(), - user: TestData.detailedUser2, + user: UserLite.fromJson(TestData.detailedUser2.toJson()), type: ":ai_yay:") ]); await tester.pumpWidget(buildTestWidget( diff --git a/test/view/note_create_page/note_create_page_test.dart b/test/view/note_create_page/note_create_page_test.dart index 00b85aed3..30d45cfc4 100644 --- a/test/view/note_create_page/note_create_page_test.dart +++ b/test/view/note_create_page/note_create_page_test.dart @@ -904,8 +904,8 @@ void main() { final misskey = MockMisskey(); final users = MockMisskeyUsers(); when(misskey.users).thenReturn(users); - when(users.show(any)) - .thenAnswer((_) async => TestData.usersShowResponse2); + when(users.showByIds(any)) + .thenAnswer((_) async => [TestData.usersShowResponse2]); await tester.pumpWidget(ProviderScope( overrides: [ @@ -941,8 +941,8 @@ void main() { final misskey = MockMisskey(); final users = MockMisskeyUsers(); when(misskey.users).thenReturn(users); - when(users.show(any)) - .thenAnswer((_) async => TestData.usersShowResponse1); + when(users.showByIds(any)) + .thenAnswer((_) async => [TestData.usersShowResponse1]); await tester.pumpWidget(ProviderScope( overrides: [ misskeyProvider.overrideWith((ref, arg) => misskey), diff --git a/test/view/user_page/user_page_test.dart b/test/view/user_page/user_page_test.dart index 179efe071..ab2fe8d5c 100644 --- a/test/view/user_page/user_page_test.dart +++ b/test/view/user_page/user_page_test.dart @@ -136,11 +136,12 @@ void main() { final mockMisskey = MockMisskey(); final mockUser = MockMisskeyUsers(); when(mockMisskey.users).thenReturn(mockUser); - when(mockUser.show(any)).thenAnswer((_) async => - TestData.usersShowResponse2.copyWith( - isFollowing: false, - isLocked: false, - autoAcceptFollowed: true)); + when(mockUser.show(any)).thenAnswer( + (_) async => TestData.usersShowResponse2.copyWith( + isFollowing: false, + isLocked: false, + ), + ); await tester.pumpWidget(ProviderScope( overrides: [ @@ -161,13 +162,14 @@ void main() { final mockMisskey = MockMisskey(); final mockUser = MockMisskeyUsers(); when(mockMisskey.users).thenReturn(mockUser); - when(mockUser.show(any)).thenAnswer((_) async => - TestData.usersShowResponse2.copyWith( - isFollowing: false, - hasPendingFollowRequestFromYou: false, - isLocked: true, - isFollowed: false, - autoAcceptFollowed: false)); + when(mockUser.show(any)).thenAnswer( + (_) async => TestData.usersShowResponse2.copyWith( + isFollowing: false, + hasPendingFollowRequestFromYou: false, + isLocked: true, + isFollowed: false, + ), + ); await tester.pumpWidget(ProviderScope( overrides: [ @@ -517,7 +519,6 @@ void main() { followeeId: TestData.usersShowResponse2.id, followerId: TestData.account.i.id, followee: TestData.detailedUser2, - follower: TestData.user1, ) ]); @@ -555,7 +556,6 @@ void main() { createdAt: DateTime.now(), followeeId: TestData.account.i.id, followerId: TestData.usersShowResponse2.id, - followee: TestData.user1, follower: TestData.detailedUser2, ) ]);