Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Tweak

Manav Rathia218d0996017
diff --git a/web/packages/new/photos/services/files.ts b/web/packages/new/photos/services/files.ts
index ae9c71c81d..0c48c7b449 100644
--- a/web/packages/new/photos/services/files.ts
+++ b/web/packages/new/photos/services/files.ts
@@ -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";