Conversation
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
| ...(sortingOptions.sortFoldersFirst ? [(v: INode) => v.type !== 'folder'] : []), | ||
| // 3: Use sorting mode if NOT basename (to be able to use display name too) | ||
| ...(sortingOptions.sortingMode !== FilesSortingMode.Name ? [(v: INode) => v[sortingOptions.sortingMode]] : []), | ||
| ...(sortingOptions.sortingMode !== FilesSortingMode.Name ? [(v: INode) => v[sortingOptions.sortingMode] || v.attributes[sortingOptions.sortingMode]] : []), |
There was a problem hiding this comment.
makes is clearer, otherwise this is also evaluated if the first value is just falsy like an empty string or the number 0.
| ...(sortingOptions.sortingMode !== FilesSortingMode.Name ? [(v: INode) => v[sortingOptions.sortingMode] || v.attributes[sortingOptions.sortingMode]] : []), | |
| ...(sortingOptions.sortingMode !== FilesSortingMode.Name ? [(v: INode) => v[sortingOptions.sortingMode] ?? v.attributes[sortingOptions.sortingMode]] : []), |
There was a problem hiding this comment.
makes is clearer, otherwise this is also evaluated if the first value is just falsy like an empty string or the number 0.
Wouldn't that be better then ?
We don't really want to sort my an empty string or a 0 🤔
There was a problem hiding this comment.
Currently it should not make a difference, due to the top level things we have defined. But it could.
E.g. if you have order of value 0 you want to sort by it.
In general if there is a value for that key it should be sorted by it, only if there is no such key on the node it should sort by the key on the node's attributes, no?
There was a problem hiding this comment.
Yes, basically :)
Let me create a followup 👍
Needed for nextcloud/server#49140
Because the Trashbin view use a custom attribute key to sort https://github.com/nextcloud/server/blob/aac5859444a54e9774b794ad4b29486bbb384ea7/apps/files_trashbin/src/files_views/trashbinView.ts#L26