Skip to content

Commit

Permalink
Merge pull request #398 from poppingmoon/hide-relations
Browse files Browse the repository at this point in the history
非公開のときフォロワー数を表示しない
  • Loading branch information
shiosyakeyakini-info authored Jan 27, 2024
2 parents 2f457ad + f809ef7 commit c515b00
Show file tree
Hide file tree
Showing 28 changed files with 2,307 additions and 2,351 deletions.
32 changes: 32 additions & 0 deletions lib/extensions/user_extension.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,35 @@ extension UserExtension on User {
return "@$username${host != null ? "@$host" : ""}";
}
}

extension UserDetailedExtension on UserDetailed {
bool get isFollowersVisibleForMe {
if (this is MeDetailed) {
return true;
}

final user = this;

return switch (followersVisibility ?? ffVisibility) {
FFVisibility.public => true,
FFVisibility.followers =>
user is UserDetailedNotMeWithRelations && user.isFollowing,
FFVisibility.private || null => false,
};
}

bool get isFollowingVisibleForMe {
if (this is MeDetailed) {
return true;
}

final user = this;

return switch (followingVisibility ?? ffVisibility) {
FFVisibility.public => true,
FFVisibility.followers =>
user is UserDetailedNotMeWithRelations && user.isFollowing,
FFVisibility.private || null => false,
};
}
}
7 changes: 0 additions & 7 deletions lib/extensions/users_show_response_extension.dart

This file was deleted.

5 changes: 2 additions & 3 deletions lib/model/account.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Account with _$Account {
required String host,
required String userId,
String? token,
required IResponse i,
required MeDetailed i,
MetaResponse? meta,
}) = _Account;

Expand Down Expand Up @@ -43,7 +43,7 @@ class Account with _$Account {
userId: "",
token: null,
meta: meta,
i: IResponse(
i: MeDetailed(
id: "",
username: "",
createdAt: DateTime.now(),
Expand All @@ -58,7 +58,6 @@ class Account with _$Account {
followersCount: 0,
notesCount: 0,
publicReactions: false,
ffVisibility: "",
twoFactorEnabled: false,
usePasswordLessLogin: false,
securityKeys: false,
Expand Down
24 changes: 12 additions & 12 deletions lib/model/account.freezed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
MetaResponse? get meta => throw _privateConstructorUsedError;

Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
Expand All @@ -40,10 +40,10 @@ abstract class $AccountCopyWith<$Res> {
{String host,
String userId,
String? token,
IResponse i,
MeDetailed i,
MetaResponse? meta});

$IResponseCopyWith<$Res> get i;
$MeDetailedCopyWith<$Res> get i;
$MetaResponseCopyWith<$Res>? get meta;
}

Expand Down Expand Up @@ -82,7 +82,7 @@ class _$AccountCopyWithImpl<$Res, $Val extends Account>
i: null == i
? _value.i
: i // ignore: cast_nullable_to_non_nullable
as IResponse,
as MeDetailed,
meta: freezed == meta
? _value.meta
: meta // ignore: cast_nullable_to_non_nullable
Expand All @@ -92,8 +92,8 @@ class _$AccountCopyWithImpl<$Res, $Val extends Account>

@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);
});
}
Expand Down Expand Up @@ -122,11 +122,11 @@ abstract class _$$AccountImplCopyWith<$Res> implements $AccountCopyWith<$Res> {
{String host,
String userId,
String? token,
IResponse i,
MeDetailed i,
MetaResponse? meta});

@override
$IResponseCopyWith<$Res> get i;
$MeDetailedCopyWith<$Res> get i;
@override
$MetaResponseCopyWith<$Res>? get meta;
}
Expand Down Expand Up @@ -164,7 +164,7 @@ class __$$AccountImplCopyWithImpl<$Res>
i: null == i
? _value.i
: i // ignore: cast_nullable_to_non_nullable
as IResponse,
as MeDetailed,
meta: freezed == meta
? _value.meta
: meta // ignore: cast_nullable_to_non_nullable
Expand Down Expand Up @@ -194,7 +194,7 @@ class _$AccountImpl extends _Account {
@override
final String? token;
@override
final IResponse i;
final MeDetailed i;
@override
final MetaResponse? meta;

Expand Down Expand Up @@ -222,7 +222,7 @@ abstract class _Account extends Account {
{required final String host,
required final String userId,
final String? token,
required final IResponse i,
required final MeDetailed i,
final MetaResponse? meta}) = _$AccountImpl;
const _Account._() : super._();

Expand All @@ -235,7 +235,7 @@ abstract class _Account extends Account {
@override
String? get token;
@override
IResponse get i;
MeDetailed get i;
@override
MetaResponse? get meta;
@override
Expand Down
2 changes: 1 addition & 1 deletion lib/model/account.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 0 additions & 15 deletions lib/model/note_search_condition.freezed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ abstract class $NoteSearchConditionCopyWith<$Res> {
$Res call(
{String? query, User? user, CommunityChannel? channel, bool localOnly});

$UserCopyWith<$Res>? get user;
$CommunityChannelCopyWith<$Res>? get channel;
}

Expand Down Expand Up @@ -77,18 +76,6 @@ class _$NoteSearchConditionCopyWithImpl<$Res, $Val extends NoteSearchCondition>
) as $Val);
}

@override
@pragma('vm:prefer-inline')
$UserCopyWith<$Res>? get user {
if (_value.user == null) {
return null;
}

return $UserCopyWith<$Res>(_value.user!, (value) {
return _then(_value.copyWith(user: value) as $Val);
});
}

@override
@pragma('vm:prefer-inline')
$CommunityChannelCopyWith<$Res>? get channel {
Expand All @@ -113,8 +100,6 @@ abstract class _$$NoteSearchConditionImplCopyWith<$Res>
$Res call(
{String? query, User? user, CommunityChannel? channel, bool localOnly});

@override
$UserCopyWith<$Res>? get user;
@override
$CommunityChannelCopyWith<$Res>? get channel;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/providers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ final accountRepositoryProvider =
final accountsProvider =
Provider<List<Account>>((ref) => ref.watch(accountRepositoryProvider));

final iProvider = Provider.family<IResponse, Acct>((ref, acct) {
final iProvider = Provider.family<MeDetailed, Acct>((ref, acct) {
final accounts = ref.watch(accountsProvider);
final account = accounts.firstWhere((account) => account.acct == acct);
return account.i;
Expand Down
Loading

0 comments on commit c515b00

Please sign in to comment.