Skip to content

Commit

Permalink
feat: update sessions' last updated time
Browse files Browse the repository at this point in the history
  • Loading branch information
vyfor committed Dec 6, 2024
1 parent 6535683 commit 9968d94
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/messages/events/client/clear_activity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ impl OnEvent for ClearActivityEvent {
if let Some(mut session) = ctx.cord.session_manager.get_session_mut(ctx.client_id) {
ctx.cord.rich_client.clear()?;
session.last_activity = None;
session.last_updated = 0;
}

Ok(())
}
}
6 changes: 5 additions & 1 deletion src/messages/events/client/update_activity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ impl OnEvent for UpdateActivityEvent {
ctx.cord
.rich_client
.update(&Packet::new(ctx.cord.rich_client.pid, Some(&activity)))?;
session.last_activity = Some(activity);
session.set_last_activity(activity);
session.last_updated = std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.unwrap() // todo: reset all timestamps if this fails
.as_micros();
}
}
}
Expand Down

0 comments on commit 9968d94

Please sign in to comment.