store: Honor state keys for the state storage.
parent
b05fed5a3b
commit
7abf0c8805
|
@ -523,7 +523,7 @@ impl BaseClient {
|
|||
) -> (
|
||||
InviteState,
|
||||
BTreeMap<UserId, StrippedMemberEvent>,
|
||||
BTreeMap<String, AnyStrippedStateEvent>,
|
||||
BTreeMap<String, BTreeMap<String, AnyStrippedStateEvent>>,
|
||||
) {
|
||||
events.into_iter().fold(
|
||||
(InviteState::default(), BTreeMap::new(), BTreeMap::new()),
|
||||
|
@ -544,7 +544,10 @@ impl BaseClient {
|
|||
}
|
||||
} else {
|
||||
room_info.handle_state_event(&e);
|
||||
state_events.insert(e.content().event_type().to_owned(), e);
|
||||
state_events
|
||||
.entry(e.content().event_type().to_owned())
|
||||
.or_insert_with(BTreeMap::new)
|
||||
.insert(e.state_key().to_owned(), e);
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
|
@ -566,7 +569,7 @@ impl BaseClient {
|
|||
) -> (
|
||||
State,
|
||||
BTreeMap<UserId, MemberEvent>,
|
||||
BTreeMap<String, AnySyncStateEvent>,
|
||||
BTreeMap<String, BTreeMap<String, AnySyncStateEvent>>,
|
||||
BTreeSet<UserId>,
|
||||
) {
|
||||
let mut state = State::default();
|
||||
|
@ -610,7 +613,10 @@ impl BaseClient {
|
|||
),
|
||||
}
|
||||
} else {
|
||||
state_events.insert(event.content().event_type().to_owned(), event);
|
||||
state_events
|
||||
.entry(event.content().event_type().to_owned())
|
||||
.or_insert_with(BTreeMap::new)
|
||||
.insert(event.state_key().to_owned(), event);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -42,11 +42,11 @@ pub struct StateChanges {
|
|||
pub presence: BTreeMap<UserId, PresenceEvent>,
|
||||
|
||||
pub members: BTreeMap<RoomId, BTreeMap<UserId, MemberEvent>>,
|
||||
pub state: BTreeMap<RoomId, BTreeMap<String, AnySyncStateEvent>>,
|
||||
pub state: BTreeMap<RoomId, BTreeMap<String, BTreeMap<String, AnySyncStateEvent>>>,
|
||||
pub room_account_data: BTreeMap<RoomId, BTreeMap<String, AnyBasicEvent>>,
|
||||
pub room_infos: BTreeMap<RoomId, RoomInfo>,
|
||||
|
||||
pub stripped_state: BTreeMap<RoomId, BTreeMap<String, AnyStrippedStateEvent>>,
|
||||
pub stripped_state: BTreeMap<RoomId, BTreeMap<String, BTreeMap<String, AnyStrippedStateEvent>>>,
|
||||
pub stripped_members: BTreeMap<RoomId, BTreeMap<UserId, StrippedMemberEvent>>,
|
||||
pub invited_room_info: BTreeMap<RoomId, RoomInfo>,
|
||||
}
|
||||
|
@ -77,6 +77,8 @@ impl StateChanges {
|
|||
self.stripped_state
|
||||
.entry(room_id.to_owned())
|
||||
.or_insert_with(BTreeMap::new)
|
||||
.entry(event.content().event_type().to_string())
|
||||
.or_insert_with(BTreeMap::new)
|
||||
.insert(event.state_key().to_string(), event);
|
||||
}
|
||||
|
||||
|
@ -92,7 +94,9 @@ impl StateChanges {
|
|||
self.state
|
||||
.entry(room_id.to_owned())
|
||||
.or_insert_with(BTreeMap::new)
|
||||
.insert(event.content().event_type().to_string(), event);
|
||||
.entry(event.content().event_type().to_string())
|
||||
.or_insert_with(BTreeMap::new)
|
||||
.insert(event.state_key().to_string(), event);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -242,7 +246,8 @@ impl Store {
|
|||
}
|
||||
}
|
||||
|
||||
for (room, events) in &changes.state {
|
||||
for (room, event_types) in &changes.state {
|
||||
for events in event_types.values() {
|
||||
for event in events.values() {
|
||||
state.insert(
|
||||
format!(
|
||||
|
@ -256,6 +261,7 @@ impl Store {
|
|||
)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (room_id, summary) in &changes.room_infos {
|
||||
summaries
|
||||
|
@ -280,7 +286,8 @@ impl Store {
|
|||
}
|
||||
}
|
||||
|
||||
for (room, events) in &changes.stripped_state {
|
||||
for (room, event_types) in &changes.stripped_state {
|
||||
for events in event_types.values() {
|
||||
for event in events.values() {
|
||||
stripped_state.insert(
|
||||
format!(
|
||||
|
@ -294,6 +301,7 @@ impl Store {
|
|||
)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue