Commit 7214a7e7 authored by Killian Kemps's avatar Killian Kemps

Avoid username duplicate in conversations list

parent f7ce8bc6
......@@ -66,13 +66,19 @@ exports.getThreadList = function(currentUserID, api, nbThreads) {
api.getThreadList('0', nbThreads, function(err, arr) {
if(err) return console.error(err);
var userInfoPromises = [];
var addedUsers = [];
// Populate threads with no name and no image
for (var i = 0; i < arr.length; i++) {
if (arr[i].isCanonicalUser || arr[i].name === '') {
if (arr[i].name === '') {
for (var z = 0; z < arr[i].participantIDs.length; z++) {
// Don't put current user in thread's names and images
if (arr[i].participantIDs[z] !== currentUserID){
userInfoPromises.push(getUserInfo(api, arr[i].participantIDs[z]));
// Avoid duplicates
if (addedUsers.indexOf(arr[i].participantIDs[z]) === -1){
userInfoPromises.push(getUserInfo(api, arr[i].participantIDs[z]));
addedUsers.push(arr[i].participantIDs[z]);
}
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment