From 59973705bb27bef9d7e0cfae325048b976850bc9 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Mon, 4 Mar 2019 12:43:14 -0800 Subject: [PATCH] modules/client/rooms/context: Provide better pagination tokens in response. --- modules/client/rooms/context.cc | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/modules/client/rooms/context.cc b/modules/client/rooms/context.cc index d1ca1aaf7..68c8a5765 100644 --- a/modules/client/rooms/context.cc +++ b/modules/client/rooms/context.cc @@ -125,12 +125,18 @@ get__context(client &client, for(size_t i(0); i < limit && before; --before, ++i) { const m::event &event{*before}; - if(!visible(event, request.user_id)) - break; - start = at<"event_id"_>(event); + if(!visible(event, request.user_id)) + continue; + array.append(event); } + + if(before) + --before; + + if(before) + start = before.event_id(); } json::stack::member @@ -153,12 +159,18 @@ get__context(client &client, for(size_t i(0); i < limit && after; ++after, ++i) { const m::event &event{*after}; - if(!visible(event, request.user_id)) - break; - end = at<"event_id"_>(event); + if(!visible(event, request.user_id)) + continue; + array.append(event); } + + if(after) + ++after; + + if(after) + end = after.event_id(); } json::stack::member