Fix default ordering on OnlineModView #1303
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The default order on which the packages are shown on OnlineModView is "whatever was received from the API". Old implementation cached the results in a file, where they could be written and read in the same order. When the cache was moved to IndexedDB, the order was inadvertently changed to "whatever the database returns".
To stay true to the old implementation, order of each package is stored in each entry in the database, so the result set can be ordered by this field. Dexie/IndexedDB doesn't support both filtering and ordering the results on database level, so the ordering is now on JS instead. The alternative would be to fetch all packages in order and filter packages from other communities on JS.
Determining which way is the most efficient is difficult since there seems to be a lot of arbitrary variance in the executions times, at least on the dev build. The performance of the implementation in this commit didn't seem to differ substantially from the unordered implementation, so it was deemed good enough.