Phasal types

This commit is contained in:
Manav Rathi 2024-04-24 12:21:52 +05:30
parent 58b1c4b489
commit 06dbf5fb06
No known key found for this signature in database

View file

@ -31,6 +31,8 @@ import {
FileWithCollection,
PublicUploadProps,
type FileWithCollection2,
type LivePhotoAssets,
type LivePhotoAssets2,
} from "types/upload";
import {
FinishedUploads,
@ -803,12 +805,30 @@ const cancelRemainingUploads = async () => {
await electron.setPendingUploadFiles("files", []);
};
/**
* The data needed by {@link clusterLivePhotos} to do its thing.
*
* As files progress through stages, they get more and more bits tacked on to
* them. These types document the journey.
*/
type ClusterableFile = {
localID: number;
collectionID: number;
// fileOrPath: File | ElectronFile | string;
file: File | ElectronFile | string;
}
type ClusteredFile = ClusterableFile & {
isLivePhoto: boolean;
livePhotoAssets?: LivePhotoAssets2;
}
/**
* Go through the given files, combining any sibling image + video assets into a
* single live photo when appropriate.
*/
const clusterLivePhotos = (mediaFiles: FileWithCollection2[]) => {
const result: FileWithCollection2[] = [];
const clusterLivePhotos = (mediaFiles: ClusterableFile[]) => {
const result: ClusteredFile[] = [];
mediaFiles
.sort((f, g) =>
nameAndExtension(getFileName(f.file))[0].localeCompare(