FurryChat/lib/utils/room_extension.dart

21 lines
648 B
Dart
Raw Normal View History

2020-01-19 14:07:42 +00:00
import 'package:famedlysdk/famedlysdk.dart';
2020-01-20 12:46:39 +00:00
import 'package:fluffychat/i18n/i18n.dart';
2020-01-19 14:07:42 +00:00
extension LocalizedRoomDisplayname on Room {
2020-05-05 12:55:19 +00:00
String getLocalizedDisplayname(I18n i18n) {
2020-01-19 14:07:42 +00:00
if ((this.name?.isEmpty ?? true) &&
(this.canonicalAlias?.isEmpty ?? true) &&
2020-01-19 15:56:13 +00:00
!this.isDirectChat &&
(this.mHeroes != null && this.mHeroes.isNotEmpty)) {
2020-05-05 12:55:19 +00:00
return i18n.groupWith(this.displayname);
2020-01-19 14:07:42 +00:00
}
2020-02-16 07:46:45 +00:00
if ((this.name?.isEmpty ?? true) &&
(this.canonicalAlias?.isEmpty ?? true) &&
!this.isDirectChat &&
(this.mHeroes?.isEmpty ?? true)) {
2020-05-05 12:55:19 +00:00
return i18n.emptyChat;
2020-02-16 07:46:45 +00:00
}
2020-01-19 14:07:42 +00:00
return this.displayname;
}
}