Reputation: 551
I am working on an iOS app that displays the last games a user has played. This list displays all the games that have been played in descendant order, and games can be Football
or Basketball
. The problem is that we get these games from two different endpoints that work with a paging mechanism. In other words, to fetch the data of the list, we have to hit both endpoints at the same time, and poll results of each service until we get to the final page. Every time we receive a new page response, we update the dataSource
and therefore the list.
The problem here is that I cannot figure out a way of updating this list in a clean way. Even if I request the same page number on both endpoints, the response may mess up the current list. The following example may clarify this situation better.
Imagine that each page returns 3 games. So the first response from each endpoint could be:
// Football response - Page 1
Football Game 1 - 01/20/2017
Football Game 2 - 01/12/2017
Football Game 3 - 01/10/2017
// Basketball response - Page 1
Basketball Game 1 - 01/19/2017
Basketball Game 2 - 01/18/2017
Basketball Game 3 - 01/17/2017
So the first load of the list will make it show the following values in this exact order:
Football Game 1 - 01/20/2017
Basketball Game 1 - 01/19/2017
Basketball Game 2 - 01/18/2017
Basketball Game 3 - 01/17/2017
Football Game 2 - 01/12/2017
Football Game 3 - 01/10/2017
Now we poll the results of the next page for each endpoint, and get these results:
// Football response - Page 2
Football Game 4 - 01/08/2017
Football Game 5 - 01/07/2017
Football Game 6 - 01/06/2017
// Basketball response - Page 1
Basketball Game 4 - 01/16/2017
Basketball Game 5 - 01/15/2017
Basketball Game 6 - 01/14/2017
Therefore, the list will have to look like this:
Football Game 1 - 01/20/2017
Basketball Game 1 - 01/19/2017
Basketball Game 2 - 01/18/2017
Basketball Game 3 - 01/17/2017
Basketball Game 4 - 01/16/2017 *
Basketball Game 5 - 01/15/2017 *
Basketball Game 6 - 01/14/2017 *
Football Game 2 - 01/12/2017
Football Game 3 - 01/10/2017
Football Game 4 - 01/08/2017
Football Game 5 - 01/07/2017
Football Game 6 - 01/06/2017
Now you can see that the rows indicated with an asterisk weren't present on the previous display, but aren't located at the bottom of the list since these games were played before than other football games. This generates a weird effect on the UX, as the user might get the list updated while he is scrolling at it, and loose track of what game we has looking at.
Also, descendant order must be kept so ordering the games by the time we get them isn't an option. Any ideas on how can I improve this situation?
Upvotes: 2
Views: 72