base: Rename some structs.
parent
a08f857e49
commit
ae33904a93
|
@ -58,7 +58,7 @@ use crate::{
|
||||||
AccountData, Ephemeral, JoinedRoom, LeftRoom, Presence, Rooms, State, SyncResponse,
|
AccountData, Ephemeral, JoinedRoom, LeftRoom, Presence, Rooms, State, SyncResponse,
|
||||||
Timeline,
|
Timeline,
|
||||||
},
|
},
|
||||||
rooms::{InnerSummary, Room, RoomType},
|
rooms::{RoomInfo, Room, RoomType},
|
||||||
session::Session,
|
session::Session,
|
||||||
store::{StateChanges, Store},
|
store::{StateChanges, Store},
|
||||||
};
|
};
|
||||||
|
@ -460,7 +460,7 @@ impl BaseClient {
|
||||||
&self,
|
&self,
|
||||||
room_id: &RoomId,
|
room_id: &RoomId,
|
||||||
ruma_timeline: &api::sync::sync_events::Timeline,
|
ruma_timeline: &api::sync::sync_events::Timeline,
|
||||||
summary: &mut InnerSummary,
|
summary: &mut RoomInfo,
|
||||||
mut changes: &mut StateChanges,
|
mut changes: &mut StateChanges,
|
||||||
) -> Timeline {
|
) -> Timeline {
|
||||||
let mut timeline = Timeline::new(ruma_timeline.limited, ruma_timeline.prev_batch.clone());
|
let mut timeline = Timeline::new(ruma_timeline.limited, ruma_timeline.prev_batch.clone());
|
||||||
|
@ -509,7 +509,7 @@ impl BaseClient {
|
||||||
&self,
|
&self,
|
||||||
room_id: &RoomId,
|
room_id: &RoomId,
|
||||||
events: &[Raw<AnySyncStateEvent>],
|
events: &[Raw<AnySyncStateEvent>],
|
||||||
summary: &mut InnerSummary,
|
summary: &mut RoomInfo,
|
||||||
mut changes: &mut StateChanges,
|
mut changes: &mut StateChanges,
|
||||||
) -> State {
|
) -> State {
|
||||||
let mut state = State::default();
|
let mut state = State::default();
|
||||||
|
|
|
@ -49,7 +49,7 @@ mod rooms;
|
||||||
mod session;
|
mod session;
|
||||||
mod store;
|
mod store;
|
||||||
|
|
||||||
pub use rooms::{InnerSummary, Room, RoomMember};
|
pub use rooms::{RoomInfo, Room, RoomMember};
|
||||||
pub use store::Store;
|
pub use store::Store;
|
||||||
|
|
||||||
pub use client::{BaseClient, BaseClientConfig, RoomState, RoomStateType};
|
pub use client::{BaseClient, BaseClientConfig, RoomState, RoomStateType};
|
||||||
|
|
|
@ -28,8 +28,6 @@ use matrix_sdk_common::{
|
||||||
};
|
};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use tracing::info;
|
|
||||||
|
|
||||||
use crate::{responses::UnreadNotificationsCount, store::Store};
|
use crate::{responses::UnreadNotificationsCount, store::Store};
|
||||||
|
|
||||||
use super::RoomMember;
|
use super::RoomMember;
|
||||||
|
@ -38,12 +36,12 @@ use super::RoomMember;
|
||||||
pub struct Room {
|
pub struct Room {
|
||||||
room_id: Arc<RoomId>,
|
room_id: Arc<RoomId>,
|
||||||
own_user_id: Arc<UserId>,
|
own_user_id: Arc<UserId>,
|
||||||
inner: Arc<SyncMutex<InnerSummary>>,
|
inner: Arc<SyncMutex<RoomInfo>>,
|
||||||
store: Store,
|
store: Store,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
|
||||||
pub struct SomeSummary {
|
pub struct RoomSummary {
|
||||||
heroes: Vec<String>,
|
heroes: Vec<String>,
|
||||||
joined_member_count: u64,
|
joined_member_count: u64,
|
||||||
invited_member_count: u64,
|
invited_member_count: u64,
|
||||||
|
@ -66,7 +64,7 @@ impl Room {
|
||||||
own_user_id: Arc::new(own_user_id.clone()),
|
own_user_id: Arc::new(own_user_id.clone()),
|
||||||
room_id: room_id.clone(),
|
room_id: room_id.clone(),
|
||||||
store,
|
store,
|
||||||
inner: Arc::new(SyncMutex::new(InnerSummary {
|
inner: Arc::new(SyncMutex::new(RoomInfo {
|
||||||
room_id,
|
room_id,
|
||||||
room_type,
|
room_type,
|
||||||
encryption: None,
|
encryption: None,
|
||||||
|
@ -211,7 +209,7 @@ impl Room {
|
||||||
&self.own_user_id
|
&self.own_user_id
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn clone_summary(&self) -> InnerSummary {
|
pub(crate) fn clone_summary(&self) -> RoomInfo {
|
||||||
(*self.inner.lock().unwrap()).clone()
|
(*self.inner.lock().unwrap()).clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,7 +221,7 @@ impl Room {
|
||||||
self.inner.lock().unwrap().encryption.is_some()
|
self.inner.lock().unwrap().encryption.is_some()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update_summary(&self, summary: InnerSummary) {
|
pub fn update_summary(&self, summary: RoomInfo) {
|
||||||
let mut inner = self.inner.lock().unwrap();
|
let mut inner = self.inner.lock().unwrap();
|
||||||
*inner = summary;
|
*inner = summary;
|
||||||
}
|
}
|
||||||
|
@ -268,7 +266,7 @@ impl Room {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||||
pub struct InnerSummary {
|
pub struct RoomInfo {
|
||||||
pub room_id: Arc<RoomId>,
|
pub room_id: Arc<RoomId>,
|
||||||
pub room_type: RoomType,
|
pub room_type: RoomType,
|
||||||
|
|
||||||
|
@ -278,14 +276,14 @@ pub struct InnerSummary {
|
||||||
pub topic: Option<String>,
|
pub topic: Option<String>,
|
||||||
|
|
||||||
pub notification_counts: UnreadNotificationsCount,
|
pub notification_counts: UnreadNotificationsCount,
|
||||||
pub summary: SomeSummary,
|
pub summary: RoomSummary,
|
||||||
pub members_synced: bool,
|
pub members_synced: bool,
|
||||||
|
|
||||||
pub encryption: Option<EncryptionEventContent>,
|
pub encryption: Option<EncryptionEventContent>,
|
||||||
pub last_prev_batch: Option<String>,
|
pub last_prev_batch: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl InnerSummary {
|
impl RoomInfo {
|
||||||
pub fn mark_as_joined(&mut self) {
|
pub fn mark_as_joined(&mut self) {
|
||||||
self.room_type = RoomType::Joined;
|
self.room_type = RoomType::Joined;
|
||||||
}
|
}
|
||||||
|
@ -314,7 +312,6 @@ impl InnerSummary {
|
||||||
pub fn handle_state_event(&mut self, event: &AnySyncStateEvent) -> bool {
|
pub fn handle_state_event(&mut self, event: &AnySyncStateEvent) -> bool {
|
||||||
match event {
|
match event {
|
||||||
AnySyncStateEvent::RoomEncryption(encryption) => {
|
AnySyncStateEvent::RoomEncryption(encryption) => {
|
||||||
info!("MARKING ROOM {} AS ENCRYPTED", self.room_id);
|
|
||||||
self.encryption = Some(encryption.content.clone());
|
self.encryption = Some(encryption.content.clone());
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
@ -345,8 +342,6 @@ impl InnerSummary {
|
||||||
pub(crate) fn update(&mut self, summary: &RumaSummary) -> bool {
|
pub(crate) fn update(&mut self, summary: &RumaSummary) -> bool {
|
||||||
let mut changed = false;
|
let mut changed = false;
|
||||||
|
|
||||||
info!("UPDAGING SUMMARY FOR {} WITH {:#?}", self.room_id, summary);
|
|
||||||
|
|
||||||
if !summary.is_empty() {
|
if !summary.is_empty() {
|
||||||
if !summary.heroes.is_empty() {
|
if !summary.heroes.is_empty() {
|
||||||
self.summary.heroes = summary.heroes.clone();
|
self.summary.heroes = summary.heroes.clone();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
mod joined;
|
mod joined;
|
||||||
mod members;
|
mod members;
|
||||||
|
|
||||||
pub use joined::{InnerSummary, Room, RoomType};
|
pub use joined::{RoomInfo, Room, RoomType};
|
||||||
pub use members::RoomMember;
|
pub use members::RoomMember;
|
||||||
|
|
|
@ -12,7 +12,7 @@ use matrix_sdk_common::{
|
||||||
use sled::{transaction::TransactionResult, Config, Db, Transactional, Tree};
|
use sled::{transaction::TransactionResult, Config, Db, Transactional, Tree};
|
||||||
use tracing::info;
|
use tracing::info;
|
||||||
|
|
||||||
use crate::{rooms::InnerSummary, Session};
|
use crate::{rooms::RoomInfo, Session};
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct Store {
|
pub struct Store {
|
||||||
|
@ -35,14 +35,14 @@ pub struct StateChanges {
|
||||||
pub state: BTreeMap<RoomId, BTreeMap<String, AnySyncStateEvent>>,
|
pub state: BTreeMap<RoomId, BTreeMap<String, AnySyncStateEvent>>,
|
||||||
pub account_data: BTreeMap<String, AnyBasicEvent>,
|
pub account_data: BTreeMap<String, AnyBasicEvent>,
|
||||||
pub room_account_data: BTreeMap<RoomId, BTreeMap<String, AnyBasicEvent>>,
|
pub room_account_data: BTreeMap<RoomId, BTreeMap<String, AnyBasicEvent>>,
|
||||||
pub room_summaries: BTreeMap<RoomId, InnerSummary>,
|
pub room_summaries: BTreeMap<RoomId, RoomInfo>,
|
||||||
// display_names: BTreeMap<RoomId, BTreeMap<String, BTreeMap<UserId, ()>>>,
|
// display_names: BTreeMap<RoomId, BTreeMap<String, BTreeMap<UserId, ()>>>,
|
||||||
pub joined_user_ids: BTreeMap<RoomId, Vec<UserId>>,
|
pub joined_user_ids: BTreeMap<RoomId, Vec<UserId>>,
|
||||||
pub invited_user_ids: BTreeMap<RoomId, Vec<UserId>>,
|
pub invited_user_ids: BTreeMap<RoomId, Vec<UserId>>,
|
||||||
pub removed_user_ids: BTreeMap<RoomId, UserId>,
|
pub removed_user_ids: BTreeMap<RoomId, UserId>,
|
||||||
pub presence: BTreeMap<UserId, PresenceEvent>,
|
pub presence: BTreeMap<UserId, PresenceEvent>,
|
||||||
pub invitest_state: BTreeMap<RoomId, BTreeMap<String, AnyStrippedStateEvent>>,
|
pub invitest_state: BTreeMap<RoomId, BTreeMap<String, AnyStrippedStateEvent>>,
|
||||||
pub invited_room_info: BTreeMap<RoomId, InnerSummary>,
|
pub invited_room_info: BTreeMap<RoomId, RoomInfo>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl StateChanges {
|
impl StateChanges {
|
||||||
|
@ -82,7 +82,7 @@ impl StateChanges {
|
||||||
.insert(user_id, event);
|
.insert(user_id, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn add_room(&mut self, room: InnerSummary) {
|
pub fn add_room(&mut self, room: RoomInfo) {
|
||||||
self.room_summaries
|
self.room_summaries
|
||||||
.insert(room.room_id.as_ref().to_owned(), room);
|
.insert(room.room_id.as_ref().to_owned(), room);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue