-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Rename RoomInternals to Room and move Arc inside Room
- Loading branch information
Showing
19 changed files
with
356 additions
and
455 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,12 +3,12 @@ | |
// Copyright: 2023, Marc Bauer <[email protected]> | ||
// License: Mozilla Public License v2.0 (MPL v2.0) | ||
|
||
use std::sync::{Arc, OnceLock, Weak}; | ||
use std::sync::{OnceLock, Weak}; | ||
|
||
use crate::app::deps::DynRoomFactory; | ||
use crate::app::event_handlers::ClientEventDispatcherTrait; | ||
use crate::client::ClientInner; | ||
use crate::domain::rooms::models::RoomInternals; | ||
use crate::domain::rooms::models::Room; | ||
use crate::domain::shared::models::RoomType; | ||
use crate::{ClientDelegate, ClientEvent, ClientRoomEventType}; | ||
|
||
|
@@ -60,7 +60,7 @@ impl ClientEventDispatcherTrait for ClientEventDispatcher { | |
delegate.handle_event(client_inner.into(), event) | ||
} | ||
|
||
fn dispatch_room_event(&self, room: Arc<RoomInternals>, event: ClientRoomEventType) { | ||
fn dispatch_room_event(&self, room: Room, event: ClientRoomEventType) { | ||
// We're not sending events for rooms that are still pending… | ||
if room.r#type == RoomType::Unknown { | ||
return; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,6 @@ | |
// Copyright: 2023, Marc Bauer <[email protected]> | ||
// License: Mozilla Public License v2.0 (MPL v2.0) | ||
|
||
use std::sync::Arc; | ||
|
||
use anyhow::Result; | ||
use async_trait::async_trait; | ||
|
||
|
@@ -20,7 +18,7 @@ pub use rooms_event_handler::RoomsEventHandler; | |
pub use server_event::*; | ||
pub use user_state_event_handler::UserStateEventHandler; | ||
|
||
use crate::domain::rooms::models::RoomInternals; | ||
use crate::domain::rooms::models::Room; | ||
use crate::{ClientEvent, ClientRoomEventType}; | ||
|
||
mod bookmarks_event_handler; | ||
|
@@ -49,5 +47,5 @@ pub trait ServerEventHandler: SendUnlessWasm + SyncUnlessWasm { | |
#[cfg_attr(feature = "test", mockall::automock)] | ||
pub trait ClientEventDispatcherTrait: SendUnlessWasm + SyncUnlessWasm { | ||
fn dispatch_event(&self, event: ClientEvent); | ||
fn dispatch_room_event(&self, room: Arc<RoomInternals>, event: ClientRoomEventType); | ||
fn dispatch_room_event(&self, room: Room, event: ClientRoomEventType); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,6 @@ | |
// Copyright: 2023, Marc Bauer <[email protected]> | ||
// License: Mozilla Public License v2.0 (MPL v2.0) | ||
|
||
use std::sync::Arc; | ||
|
||
use anyhow::Result; | ||
use async_trait::async_trait; | ||
use tracing::info; | ||
|
@@ -23,7 +21,7 @@ use crate::app::event_handlers::{ | |
}; | ||
use crate::client_event::ClientRoomEventType; | ||
use crate::domain::messaging::models::{MessageLike, MessageLikePayload}; | ||
use crate::domain::rooms::models::RoomInternals; | ||
use crate::domain::rooms::models::Room; | ||
use crate::domain::rooms::services::{ | ||
CreateOrEnterRoomRequest, JoinRoomBehavior, JoinRoomFailureBehavior, JoinRoomRedirectBehavior, | ||
}; | ||
|
@@ -73,7 +71,7 @@ impl ServerEventHandler for RoomsEventHandler { | |
} | ||
|
||
impl RoomsEventHandler { | ||
fn get_room(&self, jid: &RoomId) -> Result<Arc<RoomInternals>> { | ||
fn get_room(&self, jid: &RoomId) -> Result<Room> { | ||
self.connected_rooms_repo | ||
.get(jid) | ||
.ok_or(anyhow::format_err!("Could not find room with jid {}", jid)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,6 @@ | |
// Copyright: 2023, Marc Bauer <[email protected]> | ||
// License: Mozilla Public License v2.0 (MPL v2.0) | ||
|
||
use std::sync::Arc; | ||
|
||
use anyhow::Result; | ||
|
||
use prose_proc_macros::InjectDependencies; | ||
|
@@ -13,7 +11,7 @@ use crate::app::deps::{ | |
DynConnectedRoomsReadOnlyRepository, DynDraftsRepository, DynRoomFactory, | ||
DynSidebarDomainService, | ||
}; | ||
use crate::domain::rooms::models::{RoomInternals, RoomSidebarState}; | ||
use crate::domain::rooms::models::{Room, RoomSidebarState}; | ||
use crate::domain::shared::models::{RoomId, RoomType}; | ||
use crate::dtos::SidebarItem as SidebarItemDTO; | ||
|
||
|
@@ -31,7 +29,7 @@ pub struct SidebarService { | |
|
||
impl SidebarService { | ||
pub async fn sidebar_items(&self) -> Vec<SidebarItemDTO> { | ||
let rooms: Vec<Arc<RoomInternals>> = self.connected_rooms_repo.get_all(); | ||
let rooms: Vec<Room> = self.connected_rooms_repo.get_all(); | ||
let mut item_dtos = vec![]; | ||
|
||
for room in rooms { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.