Skip to content

Conversation

@jleandroperez
Copy link
Contributor

@jleandroperez jleandroperez commented Sep 11, 2018

Details:

This PR implements a new tool, SyncingCoordinator, which is in charge of:

  • Figuring out whenever the next page must be displayed
  • Invoking it's delegate to actually perform the Sync OP
  • Tracking "Last Refresh Date" per Page
  • Prevent multiple Sync requests for the exact same page

It comes with batteries and unit tests.


Important Note:

The first page is considered a "Special Case", not dealt with by the Sync Coordinator. The main drive behind this decision is: we want to always sync the first page, whenever the user opens the Orders tab, no matter what.

This new component (SyncingCoordinator) handles all of the Paging-Y related logic.


Testing:

  1. Check out commit a09d4ee
  2. Perform a fresh install
  3. Open a site with (tons) of orders
  • Verify that the Skeleton UI shows up immediately, granted that there are no results
  • Verify that as you scroll down, the footer spinner gets animated
  • Verify that once you've reached THE END, the footer spinner will get turned off
  • Verify that the unit tests are okay!

@bummytime @mindgraffiti please kill and try to break this code!!!. Any suggestions will be more than welcome, including a better name for the "SyncingCoordinator".

@jleandroperez jleandroperez added the type: enhancement A request for an enhancement. label Sep 11, 2018
@jleandroperez jleandroperez added this to the External open beta milestone Sep 11, 2018
@jleandroperez jleandroperez self-assigned this Sep 11, 2018
@jleandroperez jleandroperez requested review from bummytime and mindgraffiti and removed request for bummytime September 11, 2018 20:31
@wpmobilebot
Copy link
Collaborator

1 Warning
⚠️ PR has more than 500 lines of code changing. Consider splitting into smaller PRs if possible.

Generated by 🚫 Danger

@bummytime
Copy link
Contributor

@jleandroperez, our first *Coordinator ! 😆 🎉

Copy link
Contributor

@bummytime bummytime left a comment

Choose a reason for hiding this comment

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

@jleandroperez First off smoke testing — I tested the heck out of this for 30 minutes and could not get it to fail for me! Fast network, slow network, pull-to-refresh while syncing, dismissing the app while syncing, etc. It worked like a champ. ✅

❤️ed the unit tests! ✅

Code-wise I think this is great. I had a few general comments, but nothing that's a showstopper. I really like this new Coordinator...very well-thought out and straight-forward. ✅

:shipit: from me!!

static let defaultPageSize: Int = 75
public extension OrdersRemote {
public enum Defaults {
public static let pageSize: Int = 75
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm assuming we will lower this to 25 based on Slack discussion?


/// SyncingCoordinator: Encapsulates all of the "Last Refreshed / Should Refresh" Paging Logic.
///
class SyncingCoordinator {
Copy link
Contributor

Choose a reason for hiding this comment

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

FWIW, I think this name is just fine. 🤷‍♂️

}


// MARK: - Analyzer Methods: For unit testing purposes, marking them as `Internal`
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice! Unit test hooks FTW!

}

enum Syncing {
static let pageSize = 40
Copy link
Contributor

Choose a reason for hiding this comment

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

Just like the comment above ☝️ should this one be 25? 😄

@jleandroperez
Copy link
Contributor Author

@bummytime thanks a lot for the review!!!

  • Page Size lowered to 25 entities!
  • Added SyncCoordinator docs, as we've discussed!

Woooooo thank you!!!

@jleandroperez jleandroperez merged commit d9b7ff4 into develop Sep 12, 2018
@jleandroperez jleandroperez deleted the issue/135-infinite-scrolling branch September 12, 2018 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: enhancement A request for an enhancement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants