Skip to content

fix: trash page sorting and show more #4967

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

Open
wants to merge 5 commits into
base: hotfixes
Choose a base branch
from

Conversation

GarvitSinghal47
Copy link
Contributor

@GarvitSinghal47 GarvitSinghal47 commented Mar 23, 2025

Fix #4850

Summary

In this PR, I have updated the load children functionality to accept an ordering parameter, defaulting to lft. Additionally, the "show more" issue mentioned in #4851 is temporarily resolved by hiding the button if no new data is loaded after clicking it. I will investigate further and provide a comprehensive PR explaining why the network request sends data after all nodes have been loaded and resolve it in another pr seperately.

Screen-Recording.1.mp4

References

Reviewer guidance

@rtibbles rtibbles self-assigned this Mar 25, 2025
Copy link
Member

@rtibbles rtibbles left a comment

Choose a reason for hiding this comment

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

This seems to be moving us in the right direction, but not clear how the backend is supporting these updates.

@@ -216,6 +216,10 @@
// eslint-disable-next-line kolibri/vue-no-undefined-string-uses
return showMoreTranslator.$tr('showMore');
},
// "hasMore" returns true only if "more" is a nonempty plain object.
Copy link
Member

Choose a reason for hiding this comment

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

When was more an empty object?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What I meant is that it's not null—not that it returns an empty object.

Copy link
Member

Choose a reason for hiding this comment

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

Right, so I was wondering why this extra check was required, as it should either be null, or be an object with values.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I usually write code with a future-proof mindset—anticipating that regardless of any backend changes, it will consistently return one of three possibilities: either an object with values, an empty object ( can be cases if we change something in code), or null.

I just like adding extra checks in the front-end to cover all conditions, making sure everything functions correctly even if the backend behavior changes in the future.

That extra check is a defensive coding measure to ensure the front-end logic remains robust.
I can remove it if you'd prefer.

// Prevent further calls if "more" is falsy or already loading.
if (!this.more || this.moreLoading) return;
this.moreLoading = true;
// Capture current item count and clone "more" parameters.
Copy link
Member

Choose a reason for hiding this comment

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

What problem is this solving?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so it is a temporary fix for this will resolve it after this pr seperately but just add a small fix for this currently
#4851

@@ -541,6 +541,14 @@ class IndexedDBResource {
collection = collection.filter(filterFn);
}
if (paginationActive) {
// Default pagination field is 'lft'
Copy link
Member

Choose a reason for hiding this comment

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

You are making updates here, but there are no updates to make this configurable in the API itself. This will work if all of the results have already been loaded into IndexedDB, but if you are loading the trash page for the first time, I am not sure how this is meant to work.

See here how the pagination for contentnodes is hardcoded to be by lft: https://github.com/learningequality/studio/blob/unstable/contentcuration/contentcuration/viewsets/contentnode.py#L670

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 trying to fix it in backend but not sure did i did it right or not

@GarvitSinghal47 GarvitSinghal47 requested a review from rtibbles April 5, 2025 09:00
@MisRob
Copy link
Member

MisRob commented Apr 30, 2025

Hi @GarvitSinghal47, is this ready for re-review?

@GarvitSinghal47
Copy link
Contributor Author

Hi @GarvitSinghal47, is this ready for re-review?

Yes just waiting for reply on this if confirmed i will remove it otherwise we can keep it as it is as well.
Screenshot (11)

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.

3 participants