Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Channel history & Paginated Result API for Rest #48

Merged
merged 32 commits into from
Feb 15, 2021

Conversation

tiholic
Copy link
Contributor

@tiholic tiholic commented Sep 29, 2020

Rest#Channel#Channel#history will return PaginatedResult.
PaginatedResult supports methods: hasNext(), isLast(), async next() and async first() as per the docs#TG

void getHistory([ably.RestHistoryParams params]) async {
    // getting channel history, by passing or omitting the optional params
    var result = await channel.history(params);

    var messages = result.items; //get messages
    var hasNextPage = result.hasNext(); //tells whether there are more results
    if(hasNextPage){    
      result = await result.next();  //fetches next page results
      messages = result.items;
    }
    if(!hasNextPage){
      result = await result.first();  //fetches first page results
      messages = result.items;
    }
}

// history with default params
getHistory();

// sorted and filtered history
getHistory(
  ably.RestHistoryParams(
    direction: 'forwards',
    limit: 10,
    start: DateTime.fromMillisecondsSinceEpoch(0),
    end: DateTime.now()
  )
);

@tiholic tiholic force-pushed the feature/realtime-authcallback branch from d67dae9 to 4522117 Compare September 29, 2020 08:18
@tiholic tiholic force-pushed the feature/rest-channel-history branch from 494cf25 to 5d4fd98 Compare September 29, 2020 08:21
@tiholic tiholic marked this pull request as ready for review October 2, 2020 18:42
@tiholic tiholic requested review from QuintinWillison and zoechi and removed request for QuintinWillison October 2, 2020 18:42
@tiholic tiholic force-pushed the feature/realtime-authcallback branch from 4522117 to a79ae46 Compare October 3, 2020 06:15
@tiholic tiholic force-pushed the feature/rest-channel-history branch from 9ad0c11 to 7bb9496 Compare October 3, 2020 06:19
@tiholic tiholic force-pushed the feature/realtime-authcallback branch from a79ae46 to 36e8507 Compare October 3, 2020 06:22
@tiholic tiholic force-pushed the feature/rest-channel-history branch from 7bb9496 to 89d43b1 Compare October 3, 2020 06:26
@tiholic tiholic self-assigned this Oct 7, 2020
@tiholic tiholic force-pushed the feature/realtime-authcallback branch from 36e8507 to b59621b Compare October 7, 2020 11:58
@tiholic tiholic force-pushed the feature/rest-channel-history branch from fcb3928 to ad0f349 Compare October 7, 2020 11:58
@tiholic tiholic added this to the Stage 2 milestone Oct 19, 2020
@tiholic tiholic force-pushed the feature/realtime-authcallback branch 4 times, most recently from 16813d0 to ca8ea08 Compare November 5, 2020 09:19
Base automatically changed from feature/realtime-authcallback to main November 6, 2020 10:22
@tiholic tiholic force-pushed the feature/rest-channel-history branch from 5df822d to b3c6097 Compare November 17, 2020 17:29
@tiholic tiholic changed the base branch from main to integration/stage-2 November 17, 2020 17:29
@tiholic tiholic force-pushed the feature/rest-channel-history branch 2 times, most recently from 75abddd to b3c6097 Compare November 24, 2020 11:26
@tiholic tiholic force-pushed the feature/rest-channel-history branch from bc479d9 to 56ab554 Compare January 8, 2021 18:37
Copy link
Contributor

@QuintinWillison QuintinWillison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've not looked at this pull request at the level of depth I would like to, but I'm short on time and we need to get a release out.

None of the comments I've made need block this pull request from landing so, @tiholic, please don't add any more commits to the underlying branch. For each of my comments, could you please either:

  1. Create an issue to defer the work to fix it until later.
  2. Create a pull request to fix it now if you have time (in which case that pull request's underlying branch should branch from the latest branch you've been working to allow the entire backlog to fold down correctly)

And then add a comment to the conversation to point towards which approach you'll take. I'll resolve the conversations later.

@@ -164,3 +170,21 @@ extern NSString *const TxMessage_data;
extern NSString *const TxMessage_name;
extern NSString *const TxMessage_extras;
@end

@interface TxPaginatedResult : NSObject
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These @interface declarations and the corresponding @implementation blocks do nothing. I would prefer that we remove them as the inference is that they add value, but they don't.

@@ -364,6 +365,31 @@ class _MyAppState extends State<MyApp> {
child: Text('Publish'),
);

Widget getRestChannelHistory() => FlatButton(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For what it's worth, I think this code could benefit from some commentary. If nothing else for each of the three cases in the if statement. It's a little bit opaque on a brief scan. I'm finding myself puzzling over why _restHistory could be null, but also why you use ?/?? at the start but a direct comparison to == null later.

This is meant to be example code so we cannot have too much commentary. Many developers taking a look will be time poor so need their hands held.

@QuintinWillison
Copy link
Contributor

Conflicts. 🤔 I'm resolving them now.

@QuintinWillison QuintinWillison merged commit 93f048c into integration/stage-2 Feb 15, 2021
@QuintinWillison QuintinWillison deleted the feature/rest-channel-history branch February 15, 2021 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants