Skip to content

Commit

Permalink
Fix read marker to calculate on all non-internal messages
Browse files Browse the repository at this point in the history
  • Loading branch information
tarkah committed Sep 23, 2024
1 parent e38c9e2 commit 9208f1d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions data/src/history/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use serde::{Deserialize, Serialize};
use tokio::fs;

use crate::history::{dir_path, Error, Kind};
use crate::{server, Message};
use crate::{message, server, Message};

#[derive(Debug, Clone, Copy, Default, Deserialize, Serialize)]
pub struct Metadata {
Expand All @@ -20,7 +20,12 @@ pub struct ReadMarker(DateTime<Utc>);

impl ReadMarker {
pub fn latest(messages: &[Message]) -> Option<Self> {
latest_triggers_unread(messages).map(Self)
messages
.iter()
.rev()
.find(|message| !matches!(message.target.source(), message::Source::Internal(_)))
.map(|message| message.server_time)
.map(Self)
}

pub fn date_time(self) -> DateTime<Utc> {
Expand Down

0 comments on commit 9208f1d

Please sign in to comment.