diff --git a/src/helpers/GroupsHelper.ts b/src/helpers/GroupsHelper.ts index be22c09..f22fa07 100644 --- a/src/helpers/GroupsHelper.ts +++ b/src/helpers/GroupsHelper.ts @@ -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 { - // TODO URGENT : implement - return groupID; + public static async GetLastActivity(userID: number, groupID: number) : Promise { + + const lastPost = await PostsHelper.GetGroupPosts(userID, groupID, 0, 1); + + return lastPost.length == 0 ? 0 : lastPost[0].timeCreate; } /** diff --git a/src/helpers/WebappHelper.ts b/src/helpers/WebappHelper.ts index 3c358e2..f5a0bf6 100644 --- a/src/helpers/WebappHelper.ts +++ b/src/helpers/WebappHelper.ts @@ -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);