Skip to content

Conversation

cbarkerms
Copy link
Contributor

#366

The service calls to Facebook are now paged - defaulting to a page size 20 and a maximum of 5 pages, which can be easily overridden.

Key changes -

▪ Update to winsdkfb nuget with paging fix

▪ (Potential) breaking changes

FacebookService.Instance.GetUserAlbumsAsync(); now returns 

    Task<IncrementalLoadingCollection<FacebookAlbumSource, FacebookAlbum>>

    Not

    Task<List<FacebookAlbum>>

FacebookService.Instance.GetUserPhotosByAlbumIdAsync(); now returns 

    Task<IncrementalLoadingCollection<FacebookPhotoSource, FacebookPhoto>> 

    Not

    Task<List<FacebookPhoto>> 

FacebookService.Instance.RequestAsync(); now returns

    Task<IncrementalLoadingCollection<FacebookRequestSource<T>, T>>

    Not

    Task<List<T>>

These generally will not require changes if you are assigning directly to an ItemsSource, or letting the compiler figure the type out with a 'var'. The SampleApp for example did not require any changes.

@dnfclas
Copy link

dnfclas commented Oct 27, 2016

Hi @cbarkerms, I'm your friendly neighborhood .NET Foundation Pull Request Bot (You can call me DNFBOT). Thanks for your contribution!

In order for us to evaluate and accept your PR, we ask that you sign a contribution license agreement. It's all electronic and will take just minutes. I promise there's no faxing. https://cla2.dotnetfoundation.org.

TTYL, DNFBOT;

@deltakosh
Copy link
Contributor

regarding breaking changes: Is there a way to keep the previous signatures and add new methods which return the incremental collections

@cbarkerms
Copy link
Contributor Author

I considered that, but it was going to result in bloat and the breaking changes are minor (and in many cases non-existent) IMO.

@deltakosh
Copy link
Contributor

I would love to get more thoughts here. You're still returning an IList. So this could be enough.

public async Task<List<FacebookPost>> RequestAsync(FacebookDataConfig config, int maxRecords = 20)
{
return RequestAsync<FacebookPost>(config, maxRecords);
return await RequestAsync<FacebookPost>(config, maxRecords, FacebookPost.Fields);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that async/await is not required

Copy link
Contributor

Choose a reason for hiding this comment

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

agreed not need to await.. just return the task and let the caller await

"Microsoft.NETCore.UniversalWindowsPlatform": "5.1.0",
"StyleCop.Analyzers": "1.0.0",
"winsdkfb": "0.11.20160720.1"
"winsdkfb": "0.12.20161020.4"
Copy link
Contributor

Choose a reason for hiding this comment

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

we need to update the nuspec as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done


// Get current user's photo albums
await FacebookService.Instance.GetUserAlbumsAsync();
await FacebookService.Instance.GetUserAlbumsAsync(20, FacebookAlbum.Fields);
Copy link
Contributor

Choose a reason for hiding this comment

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

why adding Fields here?

Copy link
Contributor

Choose a reason for hiding this comment

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

we have a method with original signature.. we should continue using that.. no need to change that here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Either GetUserAlbumsAsync() or GetUserAlbumsAsync(20) result in an ambiguous call:

The call is ambiguous between the following methods or properties: 'FacebookService.GetUserAlbumsAsync(int, string)' and 'FacebookService.GetUserAlbumsAsync(int, string, int)'

Here are the two overloads:

  1. public async Task<List> GetUserAlbumsAsync(int maxRecords = 20, string fields = null)
  2. public async Task<IncrementalLoadingCollection<FacebookRequestSource, FacebookAlbum>> GetUserAlbumsAsync(int pageSize = 20, string fields = null, int maxPages = 5)

#1 is the original, unchanged signature. I could remove optionals off of #2 to resolve? New signature would be:

public async Task<IncrementalLoadingCollection<FacebookRequestSource, FacebookAlbum>> GetUserAlbumsAsync(int pageSize, int maxPages, string fields = null)

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this makes sense as you will call the second one for paging support


// Get current user's photo albums
await FacebookService.Instance.GetUserAlbumsAsync();
await FacebookService.Instance.GetUserAlbumsAsync(20, FacebookAlbum.Fields);
Copy link
Contributor

Choose a reason for hiding this comment

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

methods with original signatures have been added.. should we not leave them as is ? or are we marking those obsolete and suggesting use of new ones ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

please see above - we can potentially avoid deprecating...

@deltakosh
Copy link
Contributor

Some headers are missing (the CI failed) and you need to sign the CLA from DNF :)

@dnfclas
Copy link

dnfclas commented Oct 31, 2016

@cbarkerms, Thanks for signing the contribution license agreement so quickly! Actual humans will now validate the agreement and then evaluate the PR.

Thanks, DNFBOT;

@hermitdave hermitdave merged commit 3844fcc into dev Oct 31, 2016
@deltakosh deltakosh deleted the cbarker/fbpagingsupport branch October 31, 2016 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants