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

[IncrementalLoadingCollection] CurrentPageIndex should not increase if LoadDataAsync failed. #3841

Closed
HppZ opened this issue Mar 15, 2021 · 5 comments · Fixed by #3852
Closed
Assignees
Labels
Completed 🔥 functional testing required 📌 help wanted Issues identified as good community contribution opportunities question ❔ Issues or PR require more information testing 🏗️
Milestone

Comments

@HppZ
Copy link

HppZ commented Mar 15, 2021

var result = await Source.GetPagedItemsAsync(CurrentPageIndex++, ItemsPerPage, cancellationToken);
I think CurrentPageIndex should not increase if LoadDataAsync failed.

@HppZ HppZ added the question ❔ Issues or PR require more information label Mar 15, 2021
@ghost ghost added the needs triage 🔍 label Mar 15, 2021
@ghost
Copy link

ghost commented Mar 15, 2021

Hello HppZ, thank you for your interest in Windows Community Toolkit!

I have automatically added a "needs triage" label to help get things started. Our team will analyze and investigate the issue, and escalate it to the relevant team if possible.. Other community members may also answer the question and provide feedback 🙌

@HppZ HppZ changed the title [IncrementalLoadingCollection] CurrentPageIndex does not decrease by 1 if LoadDataAsync failed. [IncrementalLoadingCollection] CurrentPageIndex should not increase if LoadDataAsync failed. Mar 15, 2021
@Kyaa-dost
Copy link
Contributor

Thanks, @HppZ for highlighting the issue. I will open this up for discussion with the community and see what they think about this.

@michael-hawker
Copy link
Member

@HppZ is there a particular case you're seeing this fail? Or you just meant in general if it's a failed http request or something?

Thinking we should have some tests around these scenario to ensure we don't skip pages either if multiple requests come in at once. The behavior of ISupportIncrementalLoading isn't really well specified in the docs.

This code has been like this for a long time now, so let's move this to 7.1. We should add a suite of Unit Test scenarios to get expected behavior down, and then adjust our code from there to match.

@michael-hawker michael-hawker modified the milestones: 7.0.1, 7.1 Mar 18, 2021
@michael-hawker michael-hawker added the help wanted Issues identified as good community contribution opportunities label Mar 18, 2021
@ghost ghost removed the help wanted Issues identified as good community contribution opportunities label Mar 18, 2021
@michael-hawker michael-hawker added functional testing required 📌 help wanted Issues identified as good community contribution opportunities testing 🏗️ labels Mar 18, 2021
@ghost ghost removed the help wanted Issues identified as good community contribution opportunities label Mar 18, 2021
@michael-hawker michael-hawker added the help wanted Issues identified as good community contribution opportunities label Mar 18, 2021
@ghost ghost removed the help wanted Issues identified as good community contribution opportunities label Mar 18, 2021
@michael-hawker michael-hawker added help wanted Issues identified as good community contribution opportunities and removed In-PR 🚀 labels Mar 18, 2021
@HppZ
Copy link
Author

HppZ commented Apr 21, 2021

yes, I think something like a failed http request should not increase CurrentPageIndex.

@HppZ
Copy link
Author

HppZ commented Apr 21, 2021

ensure we don't skip pages either if multiple requests come in at once.

absolutely right!

@ghost ghost closed this as completed in #3852 May 10, 2021
ghost pushed a commit that referenced this issue May 10, 2021
<!-- 🚨 Please Do Not skip any instructions and information mentioned below as they are all required and essential to evaluate and test the PR. By fulfilling all the required information you will be able to reduce the volume of questions and most likely help merge the PR faster 🚨 -->

<!-- 📝 It is preferred if you keep the "☑️ Allow edits by maintainers" checked in the Pull Request Template as it increases collaboration with the Toolkit maintainers by permitting commits to your PR branch (only) created from your fork.  This can let us quickly make fixes for minor typos or forgotten StyleCop issues during review without needing to wait on you doing extra work. Let us help you help us! 🎉 -->


## Fixes #3841
<!-- Add the relevant issue number after the "#" mentioned above (for ex: Fixes #1234) which will automatically close the issue once the PR is merged. -->

<!-- Add a brief overview here of the feature/bug & fix. -->
Only Increment CurrentPageIndex if Source.GetPagedItemsAsync's task completes with RanToCompletion

## PR Type
What kind of change does this PR introduce?
<!-- Please uncomment one or more that apply to this PR. -->

- Bugfix
<!-- - Feature -->
<!-- - Code style update (formatting) -->
<!-- - Refactoring (no functional changes, no api changes) -->
<!-- - Build or CI related changes -->
<!-- - Documentation content changes -->
<!-- - Sample app changes -->
<!-- - Other... Please describe: -->


## What is the current behavior?
<!-- Please describe the current behavior that you are modifying, or link to a relevant issue. -->
`CurrentPageIndex` is incremented before `GetPagedItemsAsync` completes. If it does not complete or fails it is still incremented.  

## What is the new behavior?
<!-- Describe how was this issue resolved or changed? -->
`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](../readme.md#supported)
- [ ] Pull Request has been submitted to the documentation repository [instructions](..\contributing.md#docs). Link: <!-- docs PR link -->
- [ ] Sample in sample app has been added / updated (for bug fixes / features)
    - [ ] Icon has been created (if new sample) following the [Thumbnail Style Guide and templates](https://github.com/windows-toolkit/WindowsCommunityToolkit-design-assets)
- [ ] New major technical changes in the toolkit have or will be added to the [Wiki](https://github.com/windows-toolkit/WindowsCommunityToolkit/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

<!-- If this PR contains a breaking change, please describe the impact and migration path for existing applications below. 
     Please note that breaking changes are likely to be rejected within minor release cycles or held until major versions. -->


## Other information
@ghost ghost added the Completed 🔥 label May 10, 2021
@michael-hawker michael-hawker modified the milestones: 7.1, 7.0.2 May 11, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Jul 11, 2021
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Completed 🔥 functional testing required 📌 help wanted Issues identified as good community contribution opportunities question ❔ Issues or PR require more information testing 🏗️
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants