1
0
mirror of https://gitlab.com/comunic/comunicapiv2 synced 2025-06-20 00:25:17 +00:00

Returns the list of conversations with the memberships

This commit is contained in:
2020-04-09 08:22:21 +02:00
parent 85e05ccb91
commit 0988d2ac4a
3 changed files with 41 additions and 11 deletions

View File

@ -1,6 +1,7 @@
import { UserMembershipEntry, UserMembershipType } from "../entities/UserMembershipEntry";
import { FriendsHelper } from "./FriendsHelper";
import { GroupsHelper } from "./GroupsHelper";
import { ConversationsHelper } from "./ConversationsHelper";
/**
* Web applications helper
@ -20,6 +21,7 @@ export class WebappHelper {
// Get the list of friends of the user
const friendsList = await FriendsHelper.GetList(userID);
const groupsList = await GroupsHelper.GetListUser(userID);
const conversationsList = await ConversationsHelper.GetListUser(userID);
const list : Array<UserMembershipEntry> = [];
@ -31,6 +33,13 @@ export class WebappHelper {
for(const g of groupsList) list.push(new UserMembershipEntry(
await GroupsHelper.GetLastActivity(userID, g), g, UserMembershipType.GROUP));
// Add conversations to the list
conversationsList.forEach(c => list.push(new UserMembershipEntry(
c.lastActive,
c,
UserMembershipType.CONVERSATION
)))
// Sort entries by latest activities
list.sort((a, b) => b.lastActivity - a.lastActivity);