Skip to content

Commit

Permalink
Merge pull request #992 from nextcloud-libraries/fix/files-displayname
Browse files Browse the repository at this point in the history
fix(sorting): The display name attribute is called `displayname` not `displayName` for DAV
  • Loading branch information
susnux authored Jun 18, 2024
2 parents 4e20542 + 450fb37 commit 078ca8d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions __tests__/utils/fileSorting.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ describe('sortNodes', () => {
mtime: new Date(100),
size: 100,
attributes: {
displayName: 'a',
displayname: 'a',
},
}),
file('b', 100, 100),
Expand All @@ -95,7 +95,7 @@ describe('sortNodes', () => {
mtime: new Date(100),
size: 100,
attributes: {
displayName: 'a',
displayname: 'a',
},
}),
// File with basename "b" but displayname "a"
Expand All @@ -107,7 +107,7 @@ describe('sortNodes', () => {
mtime: new Date(100),
size: 100,
attributes: {
displayName: 'a',
displayname: 'a',
},
}),
]
Expand Down
6 changes: 3 additions & 3 deletions lib/utils/fileSorting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ export function sortNodes(nodes: readonly INode[], options: FilesSortingOptions
...(sortingOptions.sortFavoritesFirst ? [(v: INode) => v.attributes?.favorite !== 1] : []),
// 2: Sort folders first if sorting by name
...(sortingOptions.sortFoldersFirst ? [(v: INode) => v.type !== 'folder'] : []),
// 3: Use sorting mode if NOT basename (to be able to use displayName too)
// 3: Use sorting mode if NOT basename (to be able to use displayname too)
...(sortingOptions.sortingMode !== FilesSortingMode.Name ? [(v: INode) => v[sortingOptions.sortingMode]] : []),
// 4: Use displayName if available, fallback to name
(v: INode) => basename(v.attributes?.displayName || v.basename),
// 4: Use displayname if available, fallback to name
(v: INode) => basename(v.attributes?.displayname || v.basename),
// 5: Finally, use basename if all previous sorting methods failed
(v: INode) => v.basename,
]
Expand Down

0 comments on commit 078ca8d

Please sign in to comment.