mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2024-11-26 07:19:23 +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 name = h.postString("name");
|
||||||
|
|
||||||
const members = [...new Set(h.postNumbersList("users"))];
|
const members = h.postNumbersSet("users");
|
||||||
|
|
||||||
// Check if the users exists
|
// Check if the users exists
|
||||||
for (const userID of members) {
|
for (const userID of members) {
|
||||||
@ -29,8 +29,8 @@ export class ConversationsController {
|
|||||||
h.error(404, "User " + userID + " not found!");
|
h.error(404, "User " + userID + " not found!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!members.includes(h.getUserId()))
|
if(!members.has(h.getUserId()))
|
||||||
members.push(h.getUserId());
|
members.add(h.getUserId());
|
||||||
|
|
||||||
const conv : BaseConversation = {
|
const conv : BaseConversation = {
|
||||||
ownerID: h.getUserId(),
|
ownerID: h.getUserId(),
|
||||||
@ -149,7 +149,7 @@ export class ConversationsController {
|
|||||||
name: c.name.length > 0 ? c.name : false,
|
name: c.name.length > 0 ? c.name : false,
|
||||||
following: c.following ? 1 : 0,
|
following: c.following ? 1 : 0,
|
||||||
saw_last_message: c.sawLastMessage ? 1 : 0,
|
saw_last_message: c.sawLastMessage ? 1 : 0,
|
||||||
members: c.members
|
members: [...c.members]
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -8,7 +8,7 @@ export interface BaseConversation {
|
|||||||
ownerID: number,
|
ownerID: number,
|
||||||
name: string,
|
name: string,
|
||||||
following: boolean,
|
following: boolean,
|
||||||
members: Array<number>
|
members: Set<number>
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Conversation extends BaseConversation {
|
export interface Conversation extends BaseConversation {
|
||||||
|
@ -271,7 +271,7 @@ export class ConversationsHelper {
|
|||||||
timeCreate: row.time_add,
|
timeCreate: row.time_add,
|
||||||
following: row.following,
|
following: row.following,
|
||||||
sawLastMessage: row.saw_last_message == 1,
|
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