[fractal/fractal-next] room: Make sure to set successor and predecessor only once



commit 584d49c184839eafbe6612cc4e316ad24ab7955a
Author: Julian Sparber <julian sparber net>
Date:   Mon Dec 27 17:39:21 2021 +0100

    room: Make sure to set successor and predecessor only once
    
    Fixes: https://gitlab.gnome.org/GNOME/fractal/-/issues/889

 src/session/room/mod.rs | 9 +++++++++
 1 file changed, 9 insertions(+)
---
diff --git a/src/session/room/mod.rs b/src/session/room/mod.rs
index c3f601c8..fd8c0f7b 100644
--- a/src/session/room/mod.rs
+++ b/src/session/room/mod.rs
@@ -1036,6 +1036,11 @@ impl Room {
 
     fn load_predecessor(&self) -> Option<()> {
         let priv_ = imp::Room::from_instance(self);
+
+        if priv_.successor.get().is_some() {
+            return None;
+        }
+
         let event = self.matrix_room().create_content()?;
         let room_id = event.predecessor?.room_id;
 
@@ -1052,6 +1057,10 @@ impl Room {
     pub fn load_successor(&self) -> Option<()> {
         let priv_ = imp::Room::from_instance(self);
 
+        if priv_.successor.get().is_some() {
+            return None;
+        }
+
         let room_id = self.matrix_room().tombstone()?.replacement_room;
 
         priv_.successor.set(room_id).unwrap();


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