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

incremnenralLoading-pageIndex-fix #3852

Merged
9 commits merged into from
May 10, 2021
Merged

incremnenralLoading-pageIndex-fix #3852

9 commits merged into from
May 10, 2021

Conversation

Rosuavio
Copy link
Contributor

@Rosuavio Rosuavio commented Mar 16, 2021

Fixes #3841

Only Increment CurrentPageIndex if Source.GetPagedItemsAsync's task completes with RanToCompletion

PR Type

What kind of change does this PR introduce?

  • Bugfix

What is the current behavior?

CurrentPageIndex is incremented before GetPagedItemsAsync completes. If it does not complete or fails it is still incremented.

What is the new behavior?

CurrentPageIndex is only incremented once GetPagedItemsAsync's Task completes with `RanToCompletion.

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tested code with current supported SDKs
  • Pull Request has been submitted to the documentation repository instructions. Link:
  • Sample in sample app has been added / updated (for bug fixes / features)
  • New major technical changes in the toolkit have or will be added to the Wiki e.g. build changes, source generators, testing infrastructure, sample creation changes, etc...
  • Tests for the changes have been added (for bug fixes / features) (if applicable)
  • Header has been added to all new source files (run build/UpdateHeaders.bat)
  • Contains NO breaking changes

Other information

@ghost
Copy link

ghost commented Mar 16, 2021

Thanks RosarioPulella for opening a Pull Request! The reviewers will test the PR and highlight if there is any conflict or changes required. If the PR is approved we will proceed to merge the pull request 🙌

@ghost ghost requested review from michael-hawker, azchohfi and Kyaa-dost March 16, 2021 20:08
@Rosuavio
Copy link
Contributor Author

Rosuavio commented Mar 17, 2021

@michael-hawker, should this target 7.0.1?

@michael-hawker michael-hawker added this to the 7.0.1 milestone Mar 17, 2021
@michael-hawker michael-hawker added auto merge ⚡ bug 🐛 An unexpected issue that highlights incorrect behavior labels Mar 17, 2021
@ghost
Copy link

ghost commented Mar 17, 2021

Hello @michael-hawker!

Because this pull request has the auto merge :zap: label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@michael-hawker
Copy link
Member

@msftbot merge if @azchohfi approves

@ghost
Copy link

ghost commented Mar 17, 2021

Hello @michael-hawker!

Because you've given me some instructions on how to help merge this pull request, I'll be modifying my merge approach. Here's how I understand your requirements for merging this pull request:

  • I'll only merge this pull request if it's approved by @azchohfi

If this doesn't seem right to you, you can tell me to cancel these instructions and use the auto-merge policy that has been configured for this repository. Try telling me "forget everything I just told you".

@Rosuavio Rosuavio changed the base branch from master to dev/7.0.1 March 18, 2021 15:37
@michael-hawker michael-hawker modified the milestones: 7.0.1, 7.1 Mar 18, 2021
@michael-hawker michael-hawker marked this pull request as draft March 18, 2021 21:11
@michael-hawker
Copy link
Member

Added comment to #3841, think we should shore up tests here and then audit the desired and current behavior.

@Rosuavio Rosuavio changed the base branch from dev/7.0.1 to master March 18, 2021 21:15
@Rosuavio Rosuavio marked this pull request as ready for review April 15, 2021 20:56
@HppZ
Copy link

HppZ commented Apr 21, 2021

Thinking we should have some tests around these scenario to ensure we don't skip pages either if multiple requests come in at once.

Originally posted by @michael-hawker in #3841 (comment)

@michael-hawker
Copy link
Member

@azchohfi mind taking a quick look at this one? If you think this feels good, I'm good worrying about more tests later and just moving forward. Seems straight-forward enough.

@michael-hawker
Copy link
Member

@HppZ since you filed the original issue, did you want to test this fix with your code? You can find out more about trying preview packages here.

If so, let us know here in the PR. We'll try and add a test in the meantime.

@Rosuavio
Copy link
Contributor Author

Rosuavio commented May 4, 2021

@michael-hawker @HppZ Just added some tests and fixed an issue with multiple requests coming in asynchronously.

var result = await Source.GetPagedItemsAsync(CurrentPageIndex++, ItemsPerPage, cancellationToken);
return result;
await _mutex.WaitAsync();
try
Copy link
Member

Choose a reason for hiding this comment

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

FYI @Sergio0694 added a helper here, but it's in the Media package. Just a note for the future, not sure if we want a TODO here for later. Not worth trying to centralize or expose now.

@HppZ
Copy link

HppZ commented May 5, 2021

how about this #3954

@Rosuavio
Copy link
Contributor Author

Rosuavio commented May 5, 2021

how about this #3954

I think it would be better to open a separate PR for that at this time. I am tracking a few issues with the IncrementalLoadingCollection and looking to open more PRs.

@azchohfi
Copy link
Contributor

azchohfi commented May 5, 2021

I love this. I would only add a test to test if one of the requests throws an exception. What is the expected behavior?

@michael-hawker
Copy link
Member

@RosarioPulella stylecop is the build CI issue:

         D:\a\1\s\UnitTests\UnitTests.UWP\UI\Collection\DataSource.cs(35,9): error SA1505: An opening brace should not be followed by a blank line. [D:\a\1\s\UnitTests\UnitTests.UWP\UnitTests.UWP.csproj]

@Rosuavio Rosuavio requested a review from michael-hawker May 6, 2021 21:42
@Rosuavio
Copy link
Contributor Author

Rosuavio commented May 6, 2021

@azchohfi @michael-hawker this should be it for this PR, take a look.

@HppZ
Copy link

HppZ commented May 10, 2021

private static readonly SemaphoreSlim _mutex = new SemaphoreSlim(1);

why it is static ?

@michael-hawker
Copy link
Member

@azchohfi we good here?

@ghost ghost merged commit e348f61 into CommunityToolkit:main May 10, 2021
@Rosuavio Rosuavio deleted the incremnenralLoading-pageIndex-fix branch May 10, 2021 17:56
@michael-hawker michael-hawker modified the milestones: 7.1, 7.0.2 May 11, 2021
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto merge ⚡ bug 🐛 An unexpected issue that highlights incorrect behavior hotfix 🌶 priority 🚩
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[IncrementalLoadingCollection] CurrentPageIndex should not increase if LoadDataAsync failed.
4 participants