1
0
mirror of https://gitlab.com/comunic/comunicapiv2 synced 2024-12-29 06:58:51 +00:00

Can get last activity of groups

This commit is contained in:
Pierre HUBERT 2020-03-21 16:43:53 +01:00
parent bf84f7814f
commit beafd7a26b
2 changed files with 7 additions and 4 deletions

View File

@ -5,6 +5,7 @@ import { NewGroup } from "../entities/NewGroup";
import { time } from "../utils/DateUtils";
import { GroupSettings } from "../entities/GroupSettings";
import { existsSync, unlinkSync } from "fs";
import { PostsHelper } from "./PostsHelper";
/**
* Groups helper
@ -536,9 +537,11 @@ export class GroupsHelper {
*
* @param groupID Target group ID
*/
public static async GetLastActivity(groupID: number) : Promise<number> {
// TODO URGENT : implement
return groupID;
public static async GetLastActivity(userID: number, groupID: number) : Promise<number> {
const lastPost = await PostsHelper.GetGroupPosts(userID, groupID, 0, 1);
return lastPost.length == 0 ? 0 : lastPost[0].timeCreate;
}
/**

View File

@ -29,7 +29,7 @@ export class WebappHelper {
// Add groups to the list
for(const g of groupsList) list.push(new UserMembershipEntry(
await GroupsHelper.GetLastActivity(g), g, UserMembershipType.GROUP));
await GroupsHelper.GetLastActivity(userID, g), g, UserMembershipType.GROUP));
// Sort entries by latest activities
list.sort((a, b) => b.lastActivity - a.lastActivity);