@@ -1045,36 +1045,24 @@ async def get_room_sync_data(
1045
1045
1046
1046
# Figure out the last bump event in the room if we're in the room.
1047
1047
if room_membership_for_user_at_to_token .membership == Membership .JOIN :
1048
- new_bump_stamp : Optional [int ] = None
1049
-
1050
- # First check the timeline events we're returning to see if one of
1051
- # those matches. We iterate backwards and take the stream ordering
1052
- # of the first event that matches the bump event types.
1053
- for timeline_event in reversed (timeline_events ):
1054
- if timeline_event .type in SLIDING_SYNC_DEFAULT_BUMP_EVENT_TYPES :
1055
- new_bump_stamp = timeline_event .internal_metadata .stream_ordering
1056
- break
1057
- else :
1058
- # If not then we query the DB for it.
1059
- last_bump_event_result = (
1060
- await self .store .get_last_event_pos_in_room_before_stream_ordering (
1061
- room_id ,
1062
- to_token .room_key ,
1063
- event_types = SLIDING_SYNC_DEFAULT_BUMP_EVENT_TYPES ,
1064
- )
1048
+ last_bump_event_result = (
1049
+ await self .store .get_last_event_pos_in_room_before_stream_ordering (
1050
+ room_id ,
1051
+ to_token .room_key ,
1052
+ event_types = SLIDING_SYNC_DEFAULT_BUMP_EVENT_TYPES ,
1065
1053
)
1066
- if last_bump_event_result is not None :
1067
- _ , new_bump_event_pos = last_bump_event_result
1068
- new_bump_stamp = new_bump_event_pos .stream
1054
+ )
1055
+
1056
+ # But if we found a bump event, use that instead
1057
+ if last_bump_event_result is not None :
1058
+ _ , new_bump_event_pos = last_bump_event_result
1069
1059
1070
- # If we found a bump event, use that instead
1071
- if new_bump_stamp is not None :
1072
1060
# If we've just joined a remote room, then the last bump event may
1073
1061
# have been backfilled (and so have a negative stream ordering).
1074
1062
# These negative stream orderings can't sensibly be compared, so
1075
1063
# instead we use the membership event position.
1076
- if new_bump_stamp > 0 :
1077
- bump_stamp = new_bump_stamp
1064
+ if new_bump_event_pos . stream > 0 :
1065
+ bump_stamp = new_bump_event_pos . stream
1078
1066
1079
1067
unstable_expanded_timeline = False
1080
1068
prev_room_sync_config = previous_connection_state .room_configs .get (room_id )
0 commit comments