π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
import type { EnteFile } from "ente-media/file";
// A file can appear once per collection with the same global file ID.
// Keep the first entry; sorting before this chooses which membership survives.
export const uniqueFilesByID = (files: EnteFile[]) => {
const seen = new Set<number>();
return files.filter(({ id }) => {
if (seen.has(id)) return false;
seen.add(id);
return true;
});
};
export const groupFilesByCollectionID = (files: EnteFile[]) =>
files.reduce((result, file) => {
const id = file.collectionID;
let cfs = result.get(id);
if (!cfs) result.set(id, (cfs = []));
cfs.push(file);
return result;
}, new Map<number, EnteFile[]>());