fluffychat/lib/utils/room_status_extension.dart
ggurdin 21b9b7e720
Fix arb types (#1848)
* chore: move over all fluffychat copy changes, revert any differenced between FluffyChat and Pangea copy

* chore: sort copy between FluffyChat and Pangea, update metadata types for FluffyChat copy

* chore: update metadata type for pangea chat copy

* chore: add placeholders to Pangea vietnamese copy
2025-02-19 13:53:32 -05:00

58 lines
1.9 KiB
Dart

import 'package:flutter/widgets.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:matrix/matrix.dart';
import '../config/app_config.dart';
extension RoomStatusExtension on Room {
String getLocalizedTypingText(BuildContext context) {
var typingText = '';
final typingUsers = this.typingUsers;
typingUsers.removeWhere((User u) => u.id == client.userID);
if (AppConfig.hideTypingUsernames) {
typingText = L10n.of(context).isTyping;
if (typingUsers.first.id != directChatMatrixID) {
typingText = L10n.of(context).numUsersTyping(typingUsers.length);
}
} else if (typingUsers.length == 1) {
typingText = L10n.of(context).isTyping;
if (typingUsers.first.id != directChatMatrixID) {
typingText =
L10n.of(context).userIsTyping(typingUsers.first.calcDisplayname());
}
} else if (typingUsers.length == 2) {
typingText = L10n.of(context).userAndUserAreTyping(
typingUsers.first.calcDisplayname(),
typingUsers[1].calcDisplayname(),
);
} else if (typingUsers.length > 2) {
typingText = L10n.of(context).isTyping;
if (typingUsers.first.id != directChatMatrixID) {
typingText =
L10n.of(context).userIsTyping(typingUsers.first.calcDisplayname());
}
}
return typingText;
}
List<User> getSeenByUsers(Timeline timeline, {String? eventId}) {
if (timeline.events.isEmpty) return [];
eventId ??= timeline.events.first.eventId;
final lastReceipts = <User>{};
// now we iterate the timeline events until we hit the first rendered event
for (final event in timeline.events) {
lastReceipts.addAll(event.receipts.map((r) => r.user));
if (event.eventId == eventId) {
break;
}
}
lastReceipts.removeWhere(
(user) =>
user.id == client.userID || user.id == timeline.events.first.senderId,
);
return lastReceipts.toList();
}
}