mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2024-11-22 05:19:22 +00:00
Use Set instead of Array for conversation members
This commit is contained in:
parent
862d8e0210
commit
abd6514b59
@ -21,7 +21,7 @@ export class ConversationsController {
|
||||
|
||||
const name = h.postString("name");
|
||||
|
||||
const members = [...new Set(h.postNumbersList("users"))];
|
||||
const members = h.postNumbersSet("users");
|
||||
|
||||
// Check if the users exists
|
||||
for (const userID of members) {
|
||||
@ -29,8 +29,8 @@ export class ConversationsController {
|
||||
h.error(404, "User " + userID + " not found!");
|
||||
}
|
||||
|
||||
if(!members.includes(h.getUserId()))
|
||||
members.push(h.getUserId());
|
||||
if(!members.has(h.getUserId()))
|
||||
members.add(h.getUserId());
|
||||
|
||||
const conv : BaseConversation = {
|
||||
ownerID: h.getUserId(),
|
||||
@ -149,7 +149,7 @@ export class ConversationsController {
|
||||
name: c.name.length > 0 ? c.name : false,
|
||||
following: c.following ? 1 : 0,
|
||||
saw_last_message: c.sawLastMessage ? 1 : 0,
|
||||
members: c.members
|
||||
members: [...c.members]
|
||||
};
|
||||
}
|
||||
}
|
@ -8,7 +8,7 @@ export interface BaseConversation {
|
||||
ownerID: number,
|
||||
name: string,
|
||||
following: boolean,
|
||||
members: Array<number>
|
||||
members: Set<number>
|
||||
}
|
||||
|
||||
export interface Conversation extends BaseConversation {
|
||||
|
@ -271,7 +271,7 @@ export class ConversationsHelper {
|
||||
timeCreate: row.time_add,
|
||||
following: row.following,
|
||||
sawLastMessage: row.saw_last_message == 1,
|
||||
members: [...await this.GetConversationMembers(row.id)]
|
||||
members: await this.GetConversationMembers(row.id)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user