[fractal] room_history: Add missing day divider between existing and old messages



commit 9e92d3e1ab79d4bd75e8c3a27c530f23d0f3e6a6
Author: Xiang Fan <sfanxiang gmail com>
Date:   Thu Feb 21 13:48:57 2019 +0800

    room_history: Add missing day divider between existing and old messages

 fractal-gtk/src/widgets/room_history.rs | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
---
diff --git a/fractal-gtk/src/widgets/room_history.rs b/fractal-gtk/src/widgets/room_history.rs
index d98a4501..bc40e24f 100644
--- a/fractal-gtk/src/widgets/room_history.rs
+++ b/fractal-gtk/src/widgets/room_history.rs
@@ -155,7 +155,20 @@ impl RoomHistory {
                 let mut data = queue.borrow_mut();
                 if let Some(mut item) = data.pop_front() {
                     let last = data.front();
+                    let mut prev_day_divider = None;
                     let mut day_divider = None;
+
+                    if let Some(first) = rows.borrow().list.back() {
+                        match first {
+                            Element::Message(ref message) => {
+                                if item.date.day() != message.date.day() {
+                                    prev_day_divider =
+                                        Some(Element::DayDivider(create_day_divider(message.date)));
+                                }
+                            }
+                            _ => (),
+                        }
+                    };
                     let has_header = {
                         if let Some(last) = last {
                             if item.date.day() != last.date.day() {
@@ -168,6 +181,9 @@ impl RoomHistory {
                         }
                     };
 
+                    if let Some(prev_day_divider) = prev_day_divider {
+                        rows.borrow_mut().add_top(prev_day_divider);
+                    }
                     if item.last_viewed && !rows.borrow().list.is_empty() {
                         let divider = Element::NewDivider(create_new_message_divider());
                         rows.borrow_mut().add_top(divider);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]