Construct a source-specific 'SourcePaginationConfig' to pass into get_pagination_rows; meaning each source doesn't have to care about its own name any more

This commit is contained in:
Paul "LeoNerd" Evans 2014-10-29 15:57:23 +00:00
parent c5a25f610a
commit d6bcffa929
6 changed files with 43 additions and 40 deletions

View file

@ -612,23 +612,14 @@ class RoomEventSource(object):
return self.store.get_room_events_max_id()
@defer.inlineCallbacks
def get_pagination_rows(self, user, pagination_config, key):
from_token = pagination_config.from_token
to_token = pagination_config.to_token
limit = pagination_config.limit
direction = pagination_config.direction
to_key = to_token.room_key if to_token else None
def get_pagination_rows(self, user, config, key):
events, next_key = yield self.store.paginate_room_events(
room_id=key,
from_key=from_token.room_key,
to_key=to_key,
direction=direction,
limit=limit,
from_key=config.from_key,
to_key=config.to_key,
direction=config.direction,
limit=config.limit,
with_feedback=True
)
next_token = from_token.copy_and_replace("room_key", next_key)
defer.returnValue((events, next_token))
defer.returnValue((events, next_key))