Tweak
This commit is contained in:
@@ -38,9 +38,18 @@ export const setLocalFiles = async (
|
||||
await localForage.setItem(tableName, files);
|
||||
};
|
||||
|
||||
export function sortFiles(files: EnteFile[], sortAsc = false) {
|
||||
// sort based on the time of creation time of the file,
|
||||
// for files with same creation time, sort based on the time of last modification
|
||||
/**
|
||||
* Sort the given list of {@link EnteFile}s.
|
||||
*
|
||||
* By default, files are sorted so that the newest one is first. The optional
|
||||
* {@link sortAsc} flag can be set to `true` to sort them so that the oldest one
|
||||
* is first.
|
||||
*/
|
||||
export const sortFiles = (files: EnteFile[], sortAsc = false) => {
|
||||
// Sort based on the time of creation time of the file.
|
||||
//
|
||||
// For files with same creation time, sort based on the time of last
|
||||
// modification.
|
||||
const factor = sortAsc ? -1 : 1;
|
||||
return files.sort((a, b) => {
|
||||
if (a.metadata.creationTime === b.metadata.creationTime) {
|
||||
@@ -51,8 +60,7 @@ export function sortFiles(files: EnteFile[], sortAsc = false) {
|
||||
}
|
||||
return factor * (b.metadata.creationTime - a.metadata.creationTime);
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
export const TRASH = "file-trash";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user