Commit 38d2d015 authored by Eisha Chen-yen-su's avatar Eisha Chen-yen-su

Message: Implement PartialEq trait

This gives a manual implementation of the PartialEq trait for Message
because deriving this trait can give false negatives. So it fixes the
issue of the "New messages" divider not showing at startup.

See https://gitlab.gnome.org/World/fractal/issues/133
parent 6b53e1db
Pipeline #10829 passed with stage
in 13 minutes and 5 seconds
......@@ -3,7 +3,7 @@ extern crate chrono;
use self::chrono::prelude::*;
#[derive(Debug)]
#[derive(PartialEq, PartialOrd)]
#[derive(PartialOrd)]
#[derive(Serialize, Deserialize)]
pub struct Message {
pub sender: String,
......@@ -52,6 +52,15 @@ impl Default for Message {
}
}
impl PartialEq for Message {
fn eq(&self, other: &Message) -> bool {
match (self.id.clone(), other.id.clone()) {
(Some(self_id), Some(other_id)) => self_id == other_id,
_ => self.sender == other.sender && self.body == other.body,
}
}
}
impl Message {
/// Generates an unique transaction id for this message
/// The txn_id is generated using the md5sum of a concatenation of the message room id, the
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment