mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-21 20:39:22 +00:00
Remove current user name from conversations members names.
This commit is contained in:
parent
5eac36c9a2
commit
2cb9a7e1c0
@ -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;
|
||||
}
|
||||
|
10
lib/utils/account_utils.dart
Normal file
10
lib/utils/account_utils.dart
Normal 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();
|
||||
}
|
Loading…
Reference in New Issue
Block a user