-
Notifications
You must be signed in to change notification settings - Fork 885
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
Sort by date on the history page #6214
base: development
Are you sure you want to change the base?
Conversation
Head branch was pushed to by a user without write access
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 |
@@ -44,14 +41,15 @@ export default defineComponent({ | |||
dataLimit: 100, | |||
searchDataLimit: 100, | |||
doCaseSensitiveSearch: false, | |||
ascending: false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ascending: false, | |
useAscendingOrder: false, |
Recommend adjusting the variable name to be more specific.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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-select
s 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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
static/locales/en-US.yaml
Outdated
@@ -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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed the sort by texts please take a look
Head branch was pushed to by a user without write access
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
I made some changes based on feedback, I switched to ft-select, I prepared the store to prepare for more sort options, when more sort options are added, historyCacheSorted would be the place to change things (instead of just an inline if a case and calls to different sorting would be necessary). in the case of this sort, it's just reversing the list not actually sorting, if other sorts would be added, we would need to stop doing that and actually sort, so a decision would have to be made if it's worth adding more sorting possibilities that would obviously make sorting slower, particularly with people with huge histories. |
Head branch was pushed to by a user without write access
Conflicts have been resolved. A maintainer will review the pull request shortly. |
I might have messed up the way I solved the conflicts (let me know if you prefer a clean PR again :(, or if something else) |
Please solve the conflicts properly, you seem to have pulled in all the commits from the development branch so now it is really difficult to tell what changes are yours and merging this PR will then reland all of the existing changes on the development branch a second time. The two usual approaches are:
As for how to fix what you have done here, I'm not sure. |
Head branch was pushed to by a user without write access
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
I reset to my latest commit, I used rebase, but I think I messed it up somehow, unsure how it ended that way you can see only my changes now, I'll try to fix the merge conflicts in a bit... HOPEFULLY not messing everything up again lol had to reset HEAD --hard <my_last_commit> then I did the rebase properly after that EDIT. that should have fixed it, sorry about the random trouble... please review when you have the chance |
…o more sort types
Head branch was pushed to by a user without write access
Conflicts have been resolved. A maintainer will review the pull request shortly. |
@@ -16,6 +18,10 @@ const getters = { | |||
|
|||
getHistoryCacheById(state) { | |||
return state.historyCacheById | |||
}, | |||
|
|||
getSortOrder(state) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Getters, mutations and actions are global in the store, please use namespaced names whenever possible (tells other developers where it comes from and avoids name conflicts).
getSortOrder(state) { | |
getHistorySortOrder(state) { |
@@ -109,6 +124,11 @@ const mutations = { | |||
state.historyCacheSorted = historyCacheSorted | |||
}, | |||
|
|||
setSortOrder(state, order) { | |||
state.useAscendingOrder = order | |||
return state.useAscendingOrder |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary return.
return state.useAscendingOrder |
@@ -109,6 +124,11 @@ const mutations = { | |||
state.historyCacheSorted = historyCacheSorted | |||
}, | |||
|
|||
setSortOrder(state, order) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setSortOrder(state, order) { | |
setHistorySortOrder(state, order) { |
getIconForSortPreference: (s) => getIconForSortPreference(s), | ||
...mapActions([ | ||
'selectSort' | ||
]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getIconForSortPreference: (s) => getIconForSortPreference(s), | |
...mapActions([ | |
'selectSort' | |
]) | |
getIconForSortPreference, | |
...mapMutations([ | |
'setHistorySortOrder' | |
]) |
historyCacheSorted: function () { | ||
return this.$store.getters.getHistoryCacheSorted | ||
return this.sortOrder === SORT_BY_VALUES['DateAddedNewest'] ? this.$store.getters.getHistoryCacheSorted : this.$store.getters.getHistoryCacheSorted.toReversed() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return this.sortOrder === SORT_BY_VALUES['DateAddedNewest'] ? this.$store.getters.getHistoryCacheSorted : this.$store.getters.getHistoryCacheSorted.toReversed() | |
return this.sortOrder === SORT_BY_VALUES.DateAddedNewest ? this.$store.getters.getHistoryCacheSorted : this.$store.getters.getHistoryCacheSorted.toReversed() |
async selectSort({ commit }, sort) { | ||
try { | ||
const order = sort | ||
commit('setSortOrder', order) | ||
} catch (errMessage) { | ||
console.error(errMessage) | ||
} | ||
}, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As this action is just a plain wrapper, there isn't any benefit to using it compared to just calling the mutation directly, so it's better to just call the mutation directly in this case.
async selectSort({ commit }, sort) { | |
try { | |
const order = sort | |
commit('setSortOrder', order) | |
} catch (errMessage) { | |
console.error(errMessage) | |
} | |
}, |
export const SORT_BY_VALUES = { | ||
DateAddedNewest: 'newestFirst', | ||
DateAddedOldest: 'oldestFirst', | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move this constant into the src/constants.js
file and add HISTORY
to its name (not worth creating a new file for a single constant, especially when we already have a file for constants that are used in multiple places).
|
||
const state = { | ||
historyCacheSorted: [], | ||
useAscendingOrder: SORT_BY_VALUES['DateAddedNewest'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
useAscendingOrder: SORT_BY_VALUES['DateAddedNewest'], | |
useAscendingOrder: SORT_BY_VALUES.DateAddedNewest, |
@@ -10,6 +11,9 @@ import FtInput from '../../components/ft-input/ft-input.vue' | |||
import FtAutoLoadNextPageWrapper from '../../components/ft-auto-load-next-page-wrapper/ft-auto-load-next-page-wrapper.vue' | |||
import FtToggleSwitch from '../../components/ft-toggle-switch/ft-toggle-switch.vue' | |||
import { ctrlFHandler } from '../../helpers/utils' | |||
import { mapActions } from 'vuex' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import { mapActions } from 'vuex' | |
import { mapMutations } from 'vuex' |
@@ -270,6 +270,10 @@ 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: | |||
Sort By: Sort By |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We really need to deduplicate this string, as this pull request will add the 6th Sort By
string/text, I'll do a separate pull request for that though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do I
- leave it like this for now then?
- hard code the string for now (since this string doesn't have translation yet for this specific instance anyways?)
- maybe reference another string for now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've opened #6495 to deduplicate the strings, if you are willing to wait until that pull request is merged and rebase, you'll be able to use the Global.Sort By
string that that pull request adds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't mind, since it's the holidays haven't had time to finish my changes, so I can wait and rebase
Sortbydate
Pull Request Type
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
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