Skip to content

Commit

Permalink
Merge pull request #1026 from nextcloud-libraries/fix/types-export
Browse files Browse the repository at this point in the history
fix: Correctly export public API
  • Loading branch information
susnux committed Jul 25, 2024
2 parents 0a37765 + 3acccbe commit 35d001f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export { Node, NodeStatus, type INode } from './files/node'
export * from './utils/filename-validation'
export { getUniqueName } from './utils/filename'
export { formatFileSize, parseFileSize } from './utils/fileSize'
export { orderBy } from './utils/sorting'
export { orderBy, type SortingOrder } from './utils/sorting'
export { sortNodes, FilesSortingMode, type FilesSortingOptions } from './utils/fileSorting'

export * from './navigation/navigation'
Expand Down
7 changes: 4 additions & 3 deletions lib/utils/fileSorting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import type { INode } from '../files/node'
import type { SortingOrder } from './sorting'
import { orderBy } from './sorting'

export enum FilesSortingMode {
Expand All @@ -21,7 +22,7 @@ export interface FilesSortingOptions {
/**
* @default 'asc'
*/
sortingOrder?: 'asc'|'desc'
sortingOrder?: SortingOrder

/**
* If set to true nodes marked as favorites are ordered on top of all other nodes
Expand Down Expand Up @@ -61,9 +62,9 @@ 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 display name too)
...(sortingOptions.sortingMode !== FilesSortingMode.Name ? [(v: INode) => v[sortingOptions.sortingMode]] : []),
// 4: Use displayname if available, fallback to name
// 4: Use display name 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
2 changes: 1 addition & 1 deletion lib/utils/sorting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import { getCanonicalLocale, getLanguage } from '@nextcloud/l10n'

type IdentifierFn<T> = (v: T) => unknown
type SortingOrder = 'asc'|'desc'
export type SortingOrder = 'asc'|'desc'

/**
* Helper to create string representation
Expand Down

0 comments on commit 35d001f

Please sign in to comment.