Retain type

This commit is contained in:
Manav Rathi
2024-09-26 13:52:31 +05:30
parent fb63b1d832
commit 41d5960d1f

View File

@@ -98,6 +98,10 @@ export interface CGroupUserEntityData {
* tailored for transmission and storage.
*/
export interface Person {
/**
* The source of the underlying data.
*/
type: "cgroup" | "cluster";
/**
* Nanoid of the underlying cgroup or {@link FaceCluster}.
*/
@@ -172,9 +176,6 @@ export const reconstructPeople = async (): Promise<Person[]> => {
// in the UI.
if (cgroup.isHidden) return undefined;
// Unnamed groups are also not shown.
const name = cgroup.name;
// Person faces from all the clusters assigned to this cgroup, sorted by
// their score.
const faces = cgroup.assigned
@@ -209,7 +210,14 @@ export const reconstructPeople = async (): Promise<Person[]> => {
displayFaceFile = highestScoringFace.file;
}
return { id, name, fileIDs, displayFaceID, displayFaceFile };
return {
type: "cgroup" as const,
id,
name: cgroup.name,
fileIDs,
displayFaceID,
displayFaceFile,
};
});
// Convert local-only clusters to people.
@@ -227,6 +235,7 @@ export const reconstructPeople = async (): Promise<Person[]> => {
);
return {
type: "cluster" as const,
id: cluster.id,
name: undefined,
fileIDs: [...new Set(faces.map((f) => f.file.id))],