2020-05-15 19:57:53 +02:00
|
|
|
import 'package:famedlysdk/famedlysdk.dart';
|
|
|
|
import 'package:fluffychat/l10n/l10n.dart';
|
|
|
|
import 'package:flutter/widgets.dart';
|
|
|
|
|
|
|
|
import 'date_time_extension.dart';
|
|
|
|
|
|
|
|
extension RoomStatusExtension on Room {
|
|
|
|
Presence get directChatPresence => client.presences[directChatMatrixID];
|
|
|
|
|
|
|
|
String getLocalizedStatus(BuildContext context) {
|
|
|
|
if (isDirectChat) {
|
2020-06-19 15:10:26 +02:00
|
|
|
if (directChatPresence != null &&
|
|
|
|
directChatPresence.presence != null &&
|
|
|
|
(directChatPresence.presence.lastActiveAgo != null ||
|
|
|
|
directChatPresence.presence.currentlyActive != null)) {
|
2020-06-10 10:07:01 +02:00
|
|
|
if (directChatPresence.presence.currentlyActive == true) {
|
2020-05-15 19:57:53 +02:00
|
|
|
return L10n.of(context).currentlyActive;
|
|
|
|
}
|
2020-06-10 10:07:01 +02:00
|
|
|
return L10n.of(context).lastActiveAgo(
|
|
|
|
DateTime.fromMillisecondsSinceEpoch(
|
|
|
|
directChatPresence.presence.lastActiveAgo)
|
|
|
|
.localizedTimeShort(context));
|
2020-05-15 19:57:53 +02:00
|
|
|
}
|
|
|
|
return L10n.of(context).lastSeenLongTimeAgo;
|
|
|
|
}
|
|
|
|
return L10n.of(context).countParticipants(mJoinedMemberCount.toString());
|
|
|
|
}
|
|
|
|
}
|