diff --git a/src/context.rs b/src/context.rs index d1300f7fa..d7aac82d1 100644 --- a/src/context.rs +++ b/src/context.rs @@ -814,7 +814,22 @@ impl Context { pub async fn get_next_msgs(&self) -> Result> { let last_msg_id = match self.get_config(Config::LastMsgId).await? { Some(s) => MsgId::new(s.parse()?), - None => MsgId::new_unset(), + None => { + // If `last_msg_id` is not set yet, + // subtract 1 from the last id, + // so a single message is returned and can + // be marked as seen. + self.sql + .query_row( + "SELECT IFNULL((SELECT MAX(id) - 1 FROM msgs), 0)", + (), + |row| { + let msg_id: MsgId = row.get(0)?; + Ok(msg_id) + }, + ) + .await? + } }; let list = self