mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-12-26 13:49:22 -05:00
Flatten _get_new_state_after_events
rejig the if statements to simplify the logic and reduce indentation
This commit is contained in:
parent
9fcbbe8e7d
commit
225dc3b4cb
@ -503,6 +503,10 @@ class EventsStore(SQLBaseStore):
|
||||
None if there are no changes to the room state, or
|
||||
a dict of (type, state_key) -> event_id].
|
||||
"""
|
||||
|
||||
if not new_latest_event_ids:
|
||||
defer.returnValue({})
|
||||
|
||||
state_sets = []
|
||||
state_groups = set()
|
||||
missing_event_ids = []
|
||||
@ -537,6 +541,9 @@ class EventsStore(SQLBaseStore):
|
||||
was_updated = True
|
||||
missing_event_ids.append(event_id)
|
||||
|
||||
if not was_updated:
|
||||
return
|
||||
|
||||
if missing_event_ids:
|
||||
# Now pull out the state for any missing events from DB
|
||||
event_to_groups = yield self._get_state_group_for_events(
|
||||
@ -549,14 +556,11 @@ class EventsStore(SQLBaseStore):
|
||||
group_to_state = yield self._get_state_for_groups(groups)
|
||||
state_sets.extend(group_to_state.itervalues())
|
||||
|
||||
if not new_latest_event_ids:
|
||||
defer.returnValue({})
|
||||
elif was_updated:
|
||||
if len(state_sets) == 1:
|
||||
# If there is only one state set, then we know what the current
|
||||
# state is.
|
||||
defer.returnValue(state_sets[0])
|
||||
else:
|
||||
|
||||
# We work out the current state by passing the state sets to the
|
||||
# state resolution algorithm. It may ask for some events, including
|
||||
# the events we have yet to persist, so we need a slightly more
|
||||
@ -595,8 +599,6 @@ class EventsStore(SQLBaseStore):
|
||||
state_map_factory=get_events,
|
||||
)
|
||||
defer.returnValue(current_state)
|
||||
else:
|
||||
return
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def _calculate_state_delta(self, room_id, current_state):
|
||||
|
Loading…
Reference in New Issue
Block a user