Skip to content

Commit

Permalink
fix: extract controller from seen by row
Browse files Browse the repository at this point in the history
  • Loading branch information
Julian KOUNE authored and hoangdat committed Sep 7, 2023
1 parent 1cbf91f commit 7aec13d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
8 changes: 6 additions & 2 deletions lib/pages/chat/events/message_time.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:intl/intl.dart';
import 'package:linagora_design_flutter/colors/linagora_ref_colors.dart';
import 'package:matrix/matrix.dart';
import 'package:linagora_design_flutter/colors/linagora_state_layer.dart';
import 'package:fluffychat/utils/room_status_extension.dart';

class MessageTime extends StatelessWidget {
const MessageTime({
Expand Down Expand Up @@ -57,9 +58,12 @@ class MessageTime extends StatelessWidget {
if (ownMessage) ...[
SizedBox(width: MessageTimeStyle.paddingTimeAndIcon),
SeenByRow(
controller,
timelineOverlayMessage: timelineOverlayMessage,
eventId: event.eventId,
participants: timeline.room.getParticipants(),
getSeenByUsers: controller.room!.getSeenByUsers(
controller.timeline!,
eventId: event.eventId,
),
eventStatus: event.status,
),
],
Expand Down
22 changes: 7 additions & 15 deletions lib/pages/chat/seen_by_row.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import 'package:fluffychat/pages/chat/events/message_time_style.dart';
import 'package:flutter/material.dart';

import 'package:fluffychat/pages/chat/chat.dart';
import 'package:fluffychat/utils/room_status_extension.dart';
import 'package:matrix/matrix.dart';

enum MessageStatus {
Expand All @@ -13,27 +10,22 @@ enum MessageStatus {
}

class SeenByRow extends StatelessWidget {
final ChatController controller;
final String? eventId;
final List<User> getSeenByUsers;
final List<User> participants;
final EventStatus? eventStatus;
final bool timelineOverlayMessage;

const SeenByRow(
this.controller, {
this.eventId,
const SeenByRow({
this.eventStatus,
Key? key,
required this.getSeenByUsers,
required this.participants,
required this.timelineOverlayMessage,
}) : super(key: key);

@override
Widget build(BuildContext context) {
final seenByUsers = controller.room!.getSeenByUsers(
controller.timeline!,
eventId: eventId,
);

return getEventIcon(context, eventStatus, seenByUsers);
return getEventIcon(context, eventStatus, getSeenByUsers);
}

MessageStatus getMessageStatus(
Expand All @@ -49,7 +41,7 @@ class SeenByRow extends StatelessWidget {
return MessageStatus.sent;
}

if (seenByUsers.length == controller.room!.getParticipants().length - 1) {
if (seenByUsers.length == participants.length - 1) {
return MessageStatus.hasBeenSeenByAll;
}

Expand Down

0 comments on commit 7aec13d

Please sign in to comment.