diff --git a/src/helpers/groups_helper.rs b/src/helpers/groups_helper.rs index dbe77b6..60a3980 100644 --- a/src/helpers/groups_helper.rs +++ b/src/helpers/groups_helper.rs @@ -9,7 +9,7 @@ use crate::data::group_id::GroupID; use crate::data::group_member::{GroupMember, GroupMembershipLevel}; use crate::data::new_group::NewGroup; use crate::data::user::UserID; -use crate::helpers::{database, likes_helper, notifications_helper, posts_helper, conversations_helper}; +use crate::helpers::{conversations_helper, database, likes_helper, notifications_helper, posts_helper}; use crate::helpers::likes_helper::LikeType; use crate::utils::date_utils::time; @@ -378,16 +378,15 @@ pub fn get_last_activity(user_id: &UserID, group_id: &GroupID) -> ResultBoxError .set_limit(1) .get_group(group_id)?; - match last_post.first() { - None => { - // No post was found - Ok(0) - } + let mut last_activity = last_post.first().map(|f| f.time_create).unwrap_or(0); - Some(p) => { - Ok(p.time_create) + for conv in conversations_helper::get_list_group(group_id)? { + if conv.last_activity > last_activity { + last_activity = conv.last_activity; } } + + Ok(last_activity) } /// Set new settings to the group, except group logo