From b5cc75161fc5c9ff4191b272e1122caeedccf017 Mon Sep 17 00:00:00 2001 From: mforesti Date: Fri, 15 Nov 2024 07:38:29 +0100 Subject: [PATCH] fix(replies): show other members replies with no answer --- lib/models/default_reply.g.dart | 2 ++ lib/models/enum.dart | 2 ++ lib/models/reply.g.dart | 2 ++ lib/models/schedule_summary.dart | 2 +- lib/models/schedule_summary.freezed.dart | 20 ++++++++++---------- lib/selectors/selectors.dart | 19 +++++++++++-------- lib/util/config.freezed.dart | 15 +++++++++++++-- 7 files changed, 41 insertions(+), 21 deletions(-) diff --git a/lib/models/default_reply.g.dart b/lib/models/default_reply.g.dart index 7e9199a..2404d0c 100644 --- a/lib/models/default_reply.g.dart +++ b/lib/models/default_reply.g.dart @@ -35,4 +35,6 @@ Map _$$DefaultReplyImplToJson(_$DefaultReplyImpl instance) => const _$ReplyOptionsEnumMap = { ReplyOptions.yes: 'yes', ReplyOptions.no: 'no', + ReplyOptions.maybe: 'maybe', + ReplyOptions.none: 'none', }; diff --git a/lib/models/enum.dart b/lib/models/enum.dart index b4a2d59..8cb54aa 100644 --- a/lib/models/enum.dart +++ b/lib/models/enum.dart @@ -9,6 +9,8 @@ enum InviteMethods { enum ReplyOptions { yes, no, + maybe, + none, } /// The different roles a user can have in a group diff --git a/lib/models/reply.g.dart b/lib/models/reply.g.dart index 803a81b..edc74d4 100644 --- a/lib/models/reply.g.dart +++ b/lib/models/reply.g.dart @@ -33,4 +33,6 @@ Map _$$ReplyImplToJson(_$ReplyImpl instance) => const _$ReplyOptionsEnumMap = { ReplyOptions.yes: 'yes', ReplyOptions.no: 'no', + ReplyOptions.maybe: 'maybe', + ReplyOptions.none: 'none', }; diff --git a/lib/models/schedule_summary.dart b/lib/models/schedule_summary.dart index 47c7d6d..5ae9d9b 100644 --- a/lib/models/schedule_summary.dart +++ b/lib/models/schedule_summary.dart @@ -29,7 +29,7 @@ sealed class ScheduleEventDetails with _$ScheduleEventDetails { required int groupId, required String displayName, required DateTime eventDate, - required List<(Member, ReplyOptions)> memberReplies, + required List<(Member, ReplyOptions?)> memberReplies, required int yesCount, ReplyOptions? myReply, int? targetMemberId, diff --git a/lib/models/schedule_summary.freezed.dart b/lib/models/schedule_summary.freezed.dart index 23a131e..38d2585 100644 --- a/lib/models/schedule_summary.freezed.dart +++ b/lib/models/schedule_summary.freezed.dart @@ -333,7 +333,7 @@ mixin _$ScheduleEventDetails { int get groupId => throw _privateConstructorUsedError; String get displayName => throw _privateConstructorUsedError; DateTime get eventDate => throw _privateConstructorUsedError; - List<(Member, ReplyOptions)> get memberReplies => + List<(Member, ReplyOptions?)> get memberReplies => throw _privateConstructorUsedError; int get yesCount => throw _privateConstructorUsedError; ReplyOptions? get myReply => throw _privateConstructorUsedError; @@ -358,7 +358,7 @@ abstract class $ScheduleEventDetailsCopyWith<$Res> { int groupId, String displayName, DateTime eventDate, - List<(Member, ReplyOptions)> memberReplies, + List<(Member, ReplyOptions?)> memberReplies, int yesCount, ReplyOptions? myReply, int? targetMemberId, @@ -411,7 +411,7 @@ class _$ScheduleEventDetailsCopyWithImpl<$Res, memberReplies: null == memberReplies ? _value.memberReplies : memberReplies // ignore: cast_nullable_to_non_nullable - as List<(Member, ReplyOptions)>, + as List<(Member, ReplyOptions?)>, yesCount: null == yesCount ? _value.yesCount : yesCount // ignore: cast_nullable_to_non_nullable @@ -445,7 +445,7 @@ abstract class _$$ScheduleEventDetailsImplCopyWith<$Res> int groupId, String displayName, DateTime eventDate, - List<(Member, ReplyOptions)> memberReplies, + List<(Member, ReplyOptions?)> memberReplies, int yesCount, ReplyOptions? myReply, int? targetMemberId, @@ -495,7 +495,7 @@ class __$$ScheduleEventDetailsImplCopyWithImpl<$Res> memberReplies: null == memberReplies ? _value._memberReplies : memberReplies // ignore: cast_nullable_to_non_nullable - as List<(Member, ReplyOptions)>, + as List<(Member, ReplyOptions?)>, yesCount: null == yesCount ? _value.yesCount : yesCount // ignore: cast_nullable_to_non_nullable @@ -526,7 +526,7 @@ class _$ScheduleEventDetailsImpl required this.groupId, required this.displayName, required this.eventDate, - required final List<(Member, ReplyOptions)> memberReplies, + required final List<(Member, ReplyOptions?)> memberReplies, required this.yesCount, this.myReply, this.targetMemberId, @@ -541,9 +541,9 @@ class _$ScheduleEventDetailsImpl final String displayName; @override final DateTime eventDate; - final List<(Member, ReplyOptions)> _memberReplies; + final List<(Member, ReplyOptions?)> _memberReplies; @override - List<(Member, ReplyOptions)> get memberReplies { + List<(Member, ReplyOptions?)> get memberReplies { if (_memberReplies is EqualUnmodifiableListView) return _memberReplies; // ignore: implicit_dynamic_type return EqualUnmodifiableListView(_memberReplies); @@ -632,7 +632,7 @@ abstract class _ScheduleEventDetails implements ScheduleEventDetails { required final int groupId, required final String displayName, required final DateTime eventDate, - required final List<(Member, ReplyOptions)> memberReplies, + required final List<(Member, ReplyOptions?)> memberReplies, required final int yesCount, final ReplyOptions? myReply, final int? targetMemberId, @@ -647,7 +647,7 @@ abstract class _ScheduleEventDetails implements ScheduleEventDetails { @override DateTime get eventDate; @override - List<(Member, ReplyOptions)> get memberReplies; + List<(Member, ReplyOptions?)> get memberReplies; @override int get yesCount; @override diff --git a/lib/selectors/selectors.dart b/lib/selectors/selectors.dart index c38ed36..63d273d 100644 --- a/lib/selectors/selectors.dart +++ b/lib/selectors/selectors.dart @@ -88,8 +88,7 @@ ScheduleEventDetails? selectScheduleForDate( if (scheduleSummary == null) return null; - Member getMember(int memberId) { - final member = state.members.entities[memberId.toString()]!; + Member getMember(Member member) { final profile = state.profiles.entities[member.profileId.toString()]; return member.copyWith( @@ -97,12 +96,16 @@ ScheduleEventDetails? selectScheduleForDate( member.displayNameOverride ?? profile?.displayName); } - final memberReplies = scheduleSummary.memberReplies.entries - .map((e) => (getMember(e.key), e.value)) - .whereNot((e) => - e.$1.id == - scheduleSummary - .targetMemberId) // Remove target user from the list below + final members = + groupMembersSelector(state, scheduleSummary.groupId.toString()); + final memberReplies = members + // Fill in the blanks for members who haven't replied + .map((m) { + final reply = scheduleSummary.memberReplies[m.id]; + return (getMember(m), reply); + }) + // Remove target user from the list below + .whereNot((e) => e.$1.id == scheduleSummary.targetMemberId) .toList(); // TODO This should be a selector and memoized diff --git a/lib/util/config.freezed.dart b/lib/util/config.freezed.dart index 968c7f4..0077194 100644 --- a/lib/util/config.freezed.dart +++ b/lib/util/config.freezed.dart @@ -129,7 +129,7 @@ class __$$ConfigImplCopyWithImpl<$Res> /// @nodoc @JsonSerializable() -class _$ConfigImpl implements _Config { +class _$ConfigImpl with DiagnosticableTreeMixin implements _Config { const _$ConfigImpl( {required this.supabaseConfigPath, required this.socialAuthWebClientId, @@ -146,10 +146,21 @@ class _$ConfigImpl implements _Config { final String socialAuthIosClientId; @override - String toString() { + String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) { return 'Config(supabaseConfigPath: $supabaseConfigPath, socialAuthWebClientId: $socialAuthWebClientId, socialAuthIosClientId: $socialAuthIosClientId)'; } + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); + properties + ..add(DiagnosticsProperty('type', 'Config')) + ..add(DiagnosticsProperty('supabaseConfigPath', supabaseConfigPath)) + ..add(DiagnosticsProperty('socialAuthWebClientId', socialAuthWebClientId)) + ..add( + DiagnosticsProperty('socialAuthIosClientId', socialAuthIosClientId)); + } + @override bool operator ==(Object other) { return identical(this, other) ||