mirror of
https://gitlab.com/comunic/comunicmobile
synced 2025-06-19 00:05:16 +00:00
Remove current user name from conversations members names.
This commit is contained in:
@ -2,6 +2,7 @@ import 'package:comunic/lists/conversations_list.dart';
|
||||
import 'package:comunic/lists/users_list.dart';
|
||||
import 'package:comunic/models/api_request.dart';
|
||||
import 'package:comunic/models/conversation.dart';
|
||||
import 'package:comunic/utils/account_utils.dart';
|
||||
|
||||
/// Conversation helper
|
||||
///
|
||||
@ -36,14 +37,23 @@ class ConversationsHelper {
|
||||
|
||||
/// Get the name of a [conversation]. This requires information about the
|
||||
/// users of this conversation
|
||||
static String getConversationName(Conversation conversation, UsersList users) {
|
||||
static String getConversationName(
|
||||
Conversation conversation, UsersList users) {
|
||||
if (conversation.has_name) return conversation.name;
|
||||
|
||||
// TODO : exclude current user name
|
||||
String name = "";
|
||||
int count = 0;
|
||||
for (int i = 0; i < 3 && i < conversation.members.length; i++)
|
||||
name +=
|
||||
(i > 0 ? ", " : "") + users.getUser(conversation.members[i]).fullName;
|
||||
if (conversation.members[i] != userID()) {
|
||||
name += (count > 0 ? ", " : "") +
|
||||
users
|
||||
.getUser(conversation.members[i])
|
||||
.fullName;
|
||||
count++;
|
||||
}
|
||||
|
||||
if(conversation.members.length > 3)
|
||||
name += ", ...";
|
||||
|
||||
return name;
|
||||
}
|
||||
|
Reference in New Issue
Block a user