♻️ Add Account, Room and Space UI store structs

This commit is contained in:
2024-05-11 15:24:49 +02:00
parent bc6b02bc34
commit 18a797bc3f
12 changed files with 152 additions and 183 deletions

View File

@@ -26,7 +26,7 @@ pub struct Space {
children: RefCell<HashSet<RoomId>>, // We don´t expect to manage nested spaces
messaging_provider: Option<Rc<dyn SpaceMessagingProviderInterface>>,
store: RefCell<Option<Box<dyn SpaceStoreProviderInterface>>>,
store: RefCell<Option<Rc<dyn SpaceStoreProviderInterface>>>,
}
impl PartialEq for Space {
@@ -57,8 +57,8 @@ impl Space {
self.messaging_provider = Some(provider);
}
pub fn set_store(&self, store: Option<Box<dyn SpaceStoreProviderInterface>>) {
*self.store.borrow_mut() = store;
pub fn set_store(&self, store: Rc<dyn SpaceStoreProviderInterface>) {
*self.store.borrow_mut() = Some(store);
}
pub fn id(&self) -> &SpaceId {
@@ -84,7 +84,7 @@ impl SpaceMessagingConsumerInterface for Space {
error!("Space::on_new_name({:?})", name);
self.name.borrow_mut().clone_from(&name);
if let Some(store) = self.store.borrow_mut().as_mut() {
if let Some(store) = self.store.borrow().as_ref() {
store.set_name(name);
}
}