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

Sortbydate #6214

Open
wants to merge 3 commits into
base: development
Choose a base branch
from
Open

Sortbydate #6214

wants to merge 3 commits into from

Conversation

jlvivero
Copy link

@jlvivero jlvivero commented Nov 22, 2024

Sortbydate

Pull Request Type

  • Bugfix
  • Feature Implementation
  • Documentation
  • Other

Related issue

Initial addition to #5595 (not sure it would be considered closed and we just make a new issue for future changes)

Description

Adds a sort by date ascending/descending toggle to the history page, this is a stopgap to adding a more fully fledged filter by setting, but I wanted to keep the changes small and incremental since design wise, some decisions have to be made and I'm not sure I'm the one that should make those decisions. (like other kinds of sorting/filtering in history page)

I also removed the second sorting it does when it does the search, since the array it uses is already sorted (in whichever order we choose), and the filter method I believe does a linear scan, it seemed unnecessary to sort twice, if we think it's necessary I can add it back and just add a condition to sort whichever way we need it to (But I don't think it's needed)

Screenshots

freetubesortby

Testing

I tested by adding random videos to history, sorting it back and forth, then doing search and sorting back and forth as well

possibly with a huge history we'd like to view how the sorting performs... I don't have a huge history at the moment, so it's hard to tell. it's expected to a certain degree

Desktop

Additional context

I stuck to the simple toggle since I was only going to do the asc/desc sorting on this PR

@github-actions github-actions bot added the PR: waiting for review For PRs that are complete, tested, and ready for review label Nov 22, 2024
@FreeTubeBot FreeTubeBot enabled auto-merge (squash) November 22, 2024 20:13
auto-merge was automatically disabled November 22, 2024 20:16

Head branch was pushed to by a user without write access

@FreeTubeBot FreeTubeBot enabled auto-merge (squash) November 22, 2024 20:16
@jlvivero
Copy link
Author

jlvivero commented Dec 3, 2024

o: it's been two weeks, hopefully this get reviewed soon so I can make any fixes necessary and/or start work on follow ups

return false
}).sort((a, b) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I haven't tested this yet and have not worked much in history.js, but from what I can tell, you are correct that this does seem to be something that should already be being handled by history.js and thus does not need any manual work being done here. If @absidue or @PikachuEXE have context on why this is being done here as well, we can add it back with a code comment containing that explanation, but this is fine from what I can see.

Copy link
Collaborator

@PikachuEXE PikachuEXE Dec 4, 2024

Choose a reason for hiding this comment

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

It's from dbf69f2 (2 years ago)
Not sure if it's still needed

Copy link
Collaborator

Choose a reason for hiding this comment

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

Another sorting is introduced 3 months ago
01dbdad
I will let @absidue decide if this is still needed

Copy link
Member

Choose a reason for hiding this comment

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

I think it should be fine to remove it here, as the history store loads it sorted from the database and keeps the array in the right order when updating the history. The sort that I added for the history import in the store a few months ago is because the import replaces the array (as it has already merged the histories at the point) so it needs to be sorted before overwriting it.

showLoadMoreButton: false,
query: '',
activeData: [],
}
},
computed: {
historyCacheSorted: function () {
return this.$store.getters.getHistoryCacheSorted
return this.ascending ? [...this.$store.getters.getHistoryCacheSorted].reverse() : this.$store.getters.getHistoryCacheSorted
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
return this.ascending ? [...this.$store.getters.getHistoryCacheSorted].reverse() : this.$store.getters.getHistoryCacheSorted
return this.ascending ? this.$store.getters.getHistoryCacheSorted.toReversed(): this.$store.getters.getHistoryCacheSorted

@@ -44,14 +41,15 @@ export default defineComponent({
dataLimit: 100,
searchDataLimit: 100,
doCaseSensitiveSearch: false,
ascending: false,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
ascending: false,
useAscendingOrder: false,

Recommend adjusting the variable name to be more specific.

Copy link
Author

Choose a reason for hiding this comment

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

sounds good, I'll change it

@@ -28,6 +28,13 @@
:default-value="doCaseSensitiveSearch"
@change="doCaseSensitiveSearch = !doCaseSensitiveSearch"
/>
<ft-toggle-switch
Copy link
Collaborator

Choose a reason for hiding this comment

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

suggestion (non-blocking): We do tend to use ft-selects for sort selections, and we may have more options for this in the future, so you may want to consider changing it. Not incredibly important at this point, though, aside from making the current labeling more likely to be temporary.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Better have consistent UI unless there is a good reason

Copy link
Author

Choose a reason for hiding this comment

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

ft-select will probably require me to make change to the store, not a problem, but I'm debating then, if I'm using ft-select I should stop using a boolean for this then, I didn't want to use an enum yet, since I don't even know if we will have sorting of anything besides date. (and if we are never sorting by anything else an enum feels unnecessary)

what are your thoughts on using an enum instead?

I can also add boolean as a type to ft-select, but I'm not sure what is the desired approach here

@@ -269,6 +269,7 @@ History:
Empty Search Message: There are no videos in your history that match your search
Search bar placeholder: "Search in History"
Case Sensitive Search: Case Sensitive Search
Sort By Date ASC: Sort By Date ASC
Copy link
Collaborator

Choose a reason for hiding this comment

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

issue: Related to the above, not a fan of this label, but hard to know of a better alternative without switching to ft-select. If you do do that, looking at the other sorting labels we have, more consistent ones would be DateWatchedOldest: Earliest Watched First and DateWatchedNewest: Latest Watched First

Copy link
Author

Choose a reason for hiding this comment

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

I was also not a big fan of the label, but I also wasn't sure what to write, I'll look into ft-select and update the label accordingly (I like the Latest/Earliest watched first label more)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: waiting for review For PRs that are complete, tested, and ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants