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

fix(Timeline): double content changed calls #1012

Merged
merged 1 commit into from
Jun 17, 2024

Conversation

GeopJr
Copy link
Owner

@GeopJr GeopJr commented Jun 17, 2024

on_content_changed runs when the content has changed. While it does run when the model's items change, it would also run at the end of requesting a page.

From what I can remember that was so we dealt with empty timelines, aka, when the request ends successfully but the model wasn't changed as there are no items in the timeline.

on_content_changed main use, while virtual, is to change the base status: are there any items? show the timeline, are there no items? show the empty state, is there an error? show the error view. So if it was ran multiple times it wouldnt have any noticeable effect.

But, at some point in 0.7, I added mass relationship requests. Instead of requesting every single account's relationship status, we can now do many at once, thus avoiding spamming the instance. This is done with a container view that overrides on_content_changed, so it requests the new relationships when new items are added/removed.

Since it would be called twice however, that would mean double the mass relationship requests, even though it was useless. So now to avoid the second on_content_changed, it only gets called when no items were added to the model.


For anyone more interested, yes, there are checks in place to avoid unnecessary mass relationship requests, by checking if accounts had already gotten their relationships. However, since both on_content_changed requests happened right after the other one, the first one didn't get the chance to finish.

@GeopJr GeopJr merged commit 11d029e into main Jun 17, 2024
5 checks passed
@GeopJr GeopJr deleted the fix/timeline/double-content-changed-calls branch June 17, 2024 17:01
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.

1 participant