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

infinity-loader needs to unhide on model change #395

Closed
Redsandro opened this issue Oct 24, 2019 · 7 comments · Fixed by #413
Closed

infinity-loader needs to unhide on model change #395

Redsandro opened this issue Oct 24, 2019 · 7 comments · Fixed by #413

Comments

@Redsandro
Copy link
Contributor

The infinity-loader will stop functioning permanently on infinity when hideOnInfinity=true. However, when the model changes and has new content because of a change in filters (similar to #331), the infinity-loader should unhide itself because we've no longer reached infinity.

I think a property on the model should be watched inside the infinity-loader helper. Not sure what that property should be, but probably something like isLoaded, isDoneLoading, canLoadMore or something that resets when the model changes.

@Redsandro
Copy link
Contributor Author

A workaround is to do check the model manually inside the helper:

{{#infinity-loader infinityModel=model hideOnInfinity=false}}
  {{#if model.canLoadMore}}
    <p>
      Loading
    </p>
  {{/if}}
{{/infinity-loader}}

But a helper should help, so this is what we're trying to do:

{{infinity-loader infinityModel=model hideOnInfinity=true loadingText="Loading"}}

@snewcomer
Copy link
Collaborator

@Redsandro Are you looking for the infinity-loader component to yield out some of it's properties so you can use it in block form? If so, that seems like a good idea!

@Redsandro
Copy link
Contributor Author

Redsandro commented Oct 25, 2019

I'm glad it's a good idea, but that's not really what I mean. 😅

The short non-# form (second example) is a nice and short helper component, making our lives and code easier. Clever helper component.

When the helper component hides itself (hideOnInfinity=true) because there are no more records to fetch in the InfinityModel, this is also expected and desired.

However, when the InfinityModel changes because filters are applied to the model after reaching infinity, the helper component should unhide itself. Otherwise, once the model changes, the InfinityModel is broken.

I created the above workaround, but it's 700% more lines of code. 🙈

@Redsandro
Copy link
Contributor Author

Redsandro commented Oct 29, 2019

A workaround is to do check the model manually inside the helper:

{{#infinity-loader infinityModel=model hideOnInfinity=false}}
  {{#if model.canLoadMore}}
    <p>
      Loading
    </p>
  {{/if}}
{{/infinity-loader}}

This actually does not work when the model reloads and the trigger component is on the screen. It will stay visible permanently. The trigger needs to scroll into view for the canLoadMore to be set to false after filtering the model. How can we work around this?

This is actually a new and separate issue. Moved to #396

@jagthedrummer
Copy link

I've been struggling with this same problem, and the workaround suggested here worked for me:

#327 (comment)

@snewcomer
Copy link
Collaborator

snewcomer commented Jan 18, 2020

Thank you for the issue! What we ultimately need to do is observe reachedInfinity and reset isVisible when it changes to false. #413

One day, we can move away from observers, but for now I think the referenced PR fixes it.

@Redsandro
Copy link
Contributor Author

Does this mean we can use the one-liner again without wrapping it in {{#unless model.reachedInfinity}}? That would be great!

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 a pull request may close this issue.

3 participants