1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-11-22 12:59:21 +00:00

Remove current user name from conversations members names.

This commit is contained in:
Pierre HUBERT 2019-04-23 18:15:29 +02:00
parent 5eac36c9a2
commit 2cb9a7e1c0
2 changed files with 24 additions and 4 deletions

View File

@ -2,6 +2,7 @@ import 'package:comunic/lists/conversations_list.dart';
import 'package:comunic/lists/users_list.dart'; import 'package:comunic/lists/users_list.dart';
import 'package:comunic/models/api_request.dart'; import 'package:comunic/models/api_request.dart';
import 'package:comunic/models/conversation.dart'; import 'package:comunic/models/conversation.dart';
import 'package:comunic/utils/account_utils.dart';
/// Conversation helper /// Conversation helper
/// ///
@ -36,14 +37,23 @@ class ConversationsHelper {
/// Get the name of a [conversation]. This requires information about the /// Get the name of a [conversation]. This requires information about the
/// users of this conversation /// 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; if (conversation.has_name) return conversation.name;
// TODO : exclude current user name
String name = ""; String name = "";
int count = 0;
for (int i = 0; i < 3 && i < conversation.members.length; i++) for (int i = 0; i < 3 && i < conversation.members.length; i++)
name += if (conversation.members[i] != userID()) {
(i > 0 ? ", " : "") + users.getUser(conversation.members[i]).fullName; name += (count > 0 ? ", " : "") +
users
.getUser(conversation.members[i])
.fullName;
count++;
}
if(conversation.members.length > 3)
name += ", ...";
return name; return name;
} }

View File

@ -0,0 +1,10 @@
import 'package:comunic/helpers/account_helper.dart';
/// Account utilities
///
/// @author Pierre HUBERT
/// Get the ID of the current user
int userID() {
return AccountHelper.getCurrentUserID();
}