Skip to content

Commit

Permalink
fix(replies): show other members replies with no answer
Browse files Browse the repository at this point in the history
  • Loading branch information
mforesti committed Nov 15, 2024
1 parent 217942d commit b5cc751
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 21 deletions.
2 changes: 2 additions & 0 deletions lib/models/default_reply.g.dart

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

2 changes: 2 additions & 0 deletions lib/models/enum.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ enum InviteMethods {
enum ReplyOptions {
yes,
no,
maybe,
none,
}

/// The different roles a user can have in a group
Expand Down
2 changes: 2 additions & 0 deletions lib/models/reply.g.dart

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

2 changes: 1 addition & 1 deletion lib/models/schedule_summary.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
20 changes: 10 additions & 10 deletions lib/models/schedule_summary.freezed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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);
Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand Down
19 changes: 11 additions & 8 deletions lib/selectors/selectors.dart
Original file line number Diff line number Diff line change
Expand Up @@ -88,21 +88,24 @@ 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(
displayNameOverride:
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
Expand Down
15 changes: 13 additions & 2 deletions lib/util/config.freezed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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) ||
Expand Down

0 comments on commit b5cc751

Please sign in to comment.