@@ -1210,6 +1210,30 @@ async def get_backfill_points_in_room(
12101210 equal to the `current_depth`. Sorted by depth, highest to lowest (descending)
12111211 so the closest events to the `current_depth` are first in the list.
12121212
1213+ Note: We can only do approximate depth comparisons. Backwards extremeties are
1214+ the oldest events we know of in the room but we only know of them because some
1215+ other event referenced them by prev_event and aren't persisted in our database
1216+ yet (meaning we don't know their depth specifically). So we need to look for the
1217+ approximate depth from the events connected to the current backwards
1218+ extremeties.
1219+
1220+ It's best to pad the `current_depth` by the number of messages you plan to
1221+ backfill from these points.
1222+
1223+ Example:
1224+
1225+ - Your pagination token represents a scroll position at `depth` of `100`.
1226+ - We have a backfill point at an approximate depth of `125`
1227+ - You plan to backfill `50` events from that backfill point.
1228+
1229+ When we pad our `current_depth`, `100` + `50` = `150`, we pick up the backfill
1230+ point at `125` (because <= `150`, our `current_depth`), backfill `50` events to
1231+ a depth of `75` in the timeline (exposing new events that we can return `100` ->
1232+ `75`).
1233+
1234+ When we don't pad our `current_depth`, `100` is lower than any of the backfill
1235+ points so we don't pick any and miss out on backfilling any events.
1236+
12131237 We ignore extremities that are newer than the user's current scroll position
12141238 (ie, those with depth greater than `current_depth`) as:
12151239 1. we don't really care about getting events that have happened
@@ -1221,7 +1245,7 @@ async def get_backfill_points_in_room(
12211245
12221246 Args:
12231247 room_id: Room where we want to find the oldest events
1224- current_depth: The depth at the user's current scrollback position
1248+ current_depth: The depth at the user's current scrollback position (see notes above).
12251249 limit: The max number of backfill points to return
12261250
12271251 Returns:
0 commit comments