type merge
This commit is contained in:
parent
b66d74c652
commit
b93638e354
15 changed files with 103 additions and 119 deletions
|
@ -1,18 +1,16 @@
|
|||
import { useContext, useEffect, useState } from "react";
|
||||
import { UploadProgressDialog } from "./dialog";
|
||||
import { MinimizedUploadProgress } from "./minimized";
|
||||
|
||||
import { t } from "i18next";
|
||||
|
||||
import { UPLOAD_STAGES } from "constants/upload";
|
||||
import UploadProgressContext from "contexts/uploadProgress";
|
||||
import { t } from "i18next";
|
||||
import { AppContext } from "pages/_app";
|
||||
import {
|
||||
import { useContext, useEffect, useState } from "react";
|
||||
import type {
|
||||
InProgressUpload,
|
||||
SegregatedFinishedUploads,
|
||||
UploadCounter,
|
||||
UploadFileNames,
|
||||
} from "types/upload/ui";
|
||||
} from "services/upload/uploadManager";
|
||||
import { UploadProgressDialog } from "./dialog";
|
||||
import { MinimizedUploadProgress } from "./minimized";
|
||||
|
||||
interface Props {
|
||||
open: boolean;
|
||||
|
|
|
@ -19,6 +19,13 @@ import {
|
|||
getPublicCollectionUploaderName,
|
||||
savePublicCollectionUploaderName,
|
||||
} from "services/publicCollectionService";
|
||||
import type {
|
||||
FileWithCollection,
|
||||
InProgressUpload,
|
||||
SegregatedFinishedUploads,
|
||||
UploadCounter,
|
||||
UploadFileNames,
|
||||
} from "services/upload/uploadManager";
|
||||
import uploadManager, {
|
||||
setToUploadCollection,
|
||||
} from "services/upload/uploadManager";
|
||||
|
@ -33,13 +40,6 @@ import {
|
|||
SetLoading,
|
||||
UploadTypeSelectorIntent,
|
||||
} from "types/gallery";
|
||||
import { type FileWithCollection } from "types/upload";
|
||||
import {
|
||||
InProgressUpload,
|
||||
SegregatedFinishedUploads,
|
||||
UploadCounter,
|
||||
UploadFileNames,
|
||||
} from "types/upload/ui";
|
||||
import { getOrCreateAlbum } from "utils/collection";
|
||||
import { PublicCollectionGalleryContext } from "utils/publicCollectionGallery";
|
||||
import {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { ENCRYPTION_CHUNK_SIZE } from "@ente/shared/crypto/constants";
|
||||
import { Location } from "types/upload";
|
||||
import { Location } from "types/metadata";
|
||||
|
||||
// this is the chunk size of the un-encrypted file which is read and encrypted before uploading it as a single part.
|
||||
export const MULTIPART_PART_SIZE = 20 * 1024 * 1024;
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import { UPLOAD_STAGES } from "constants/upload";
|
||||
import { createContext } from "react";
|
||||
import {
|
||||
import type {
|
||||
InProgressUpload,
|
||||
SegregatedFinishedUploads,
|
||||
UploadCounter,
|
||||
UploadFileNames,
|
||||
} from "types/upload/ui";
|
||||
} from "services/upload/uploadManager";
|
||||
|
||||
interface UploadProgressContextType {
|
||||
open: boolean;
|
||||
|
|
|
@ -4,7 +4,7 @@ import { validateAndGetCreationUnixTimeInMicroSeconds } from "@ente/shared/time"
|
|||
import { NULL_LOCATION } from "constants/upload";
|
||||
import exifr from "exifr";
|
||||
import piexif from "piexifjs";
|
||||
import { Location, type ParsedExtractedMetadata } from "types/upload";
|
||||
import type { Location, ParsedExtractedMetadata } from "types/metadata";
|
||||
|
||||
type ParsedEXIFData = Record<string, any> &
|
||||
Partial<{
|
||||
|
|
|
@ -9,8 +9,8 @@ import {
|
|||
outputPathPlaceholder,
|
||||
} from "constants/ffmpeg";
|
||||
import { NULL_LOCATION } from "constants/upload";
|
||||
import { ParsedExtractedMetadata } from "types/upload";
|
||||
import { type DedicatedFFmpegWorker } from "worker/ffmpeg.worker";
|
||||
import type { ParsedExtractedMetadata } from "types/metadata";
|
||||
import type { DedicatedFFmpegWorker } from "worker/ffmpeg.worker";
|
||||
|
||||
/**
|
||||
* Generate a thumbnail for the given video using a wasm FFmpeg running in a web
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import log from "@/next/log";
|
||||
import { LocationTagData } from "types/entity";
|
||||
import { Location } from "types/upload";
|
||||
import { Location } from "types/metadata";
|
||||
|
||||
export interface City {
|
||||
city: string;
|
||||
|
|
|
@ -4,7 +4,7 @@ import { ensureElectron } from "@/next/electron";
|
|||
import { nameAndExtension } from "@/next/file";
|
||||
import log from "@/next/log";
|
||||
import { NULL_LOCATION } from "constants/upload";
|
||||
import { type Location } from "types/upload";
|
||||
import type { Location } from "types/metadata";
|
||||
|
||||
export interface ParsedMetadataJSON {
|
||||
creationTime: number;
|
||||
|
@ -124,7 +124,7 @@ const parseMetadataJSONText = (text: string) => {
|
|||
parsedMetadataJSON.modificationTime =
|
||||
metadataJSON["modificationTime"]["timestamp"] * 1000000;
|
||||
}
|
||||
let locationData: Location = NULL_LOCATION;
|
||||
let locationData: Location = { ...NULL_LOCATION };
|
||||
if (
|
||||
metadataJSON["geoData"] &&
|
||||
(metadataJSON["geoData"]["latitude"] !== 0.0 ||
|
||||
|
|
|
@ -28,18 +28,6 @@ import watcher from "services/watch";
|
|||
import { Collection } from "types/collection";
|
||||
import { EncryptedEnteFile, EnteFile } from "types/file";
|
||||
import { SetFiles } from "types/gallery";
|
||||
import {
|
||||
FileWithCollection,
|
||||
PublicUploadProps,
|
||||
type LivePhotoAssets,
|
||||
} from "types/upload";
|
||||
import {
|
||||
FinishedUploads,
|
||||
InProgressUpload,
|
||||
InProgressUploads,
|
||||
ProgressUpdater,
|
||||
SegregatedFinishedUploads,
|
||||
} from "types/upload/ui";
|
||||
import { decryptFile, getUserOwnedFiles, sortFiles } from "utils/file";
|
||||
import { getLocalFiles } from "../fileService";
|
||||
import {
|
||||
|
@ -49,9 +37,70 @@ import {
|
|||
} from "./takeout";
|
||||
import UploadService, { fopFileName, fopSize, uploader } from "./uploadService";
|
||||
|
||||
export type FileID = number;
|
||||
|
||||
export type PercentageUploaded = number;
|
||||
/* localID => fileName */
|
||||
export type UploadFileNames = Map<FileID, string>;
|
||||
|
||||
export interface UploadCounter {
|
||||
finished: number;
|
||||
total: number;
|
||||
}
|
||||
|
||||
export interface InProgressUpload {
|
||||
localFileID: FileID;
|
||||
progress: PercentageUploaded;
|
||||
}
|
||||
|
||||
export interface FinishedUpload {
|
||||
localFileID: FileID;
|
||||
result: UPLOAD_RESULT;
|
||||
}
|
||||
|
||||
export type InProgressUploads = Map<FileID, PercentageUploaded>;
|
||||
|
||||
export type FinishedUploads = Map<FileID, UPLOAD_RESULT>;
|
||||
|
||||
export type SegregatedFinishedUploads = Map<UPLOAD_RESULT, FileID[]>;
|
||||
|
||||
export interface ProgressUpdater {
|
||||
setPercentComplete: React.Dispatch<React.SetStateAction<number>>;
|
||||
setUploadCounter: React.Dispatch<React.SetStateAction<UploadCounter>>;
|
||||
setUploadStage: React.Dispatch<React.SetStateAction<UPLOAD_STAGES>>;
|
||||
setInProgressUploads: React.Dispatch<
|
||||
React.SetStateAction<InProgressUpload[]>
|
||||
>;
|
||||
setFinishedUploads: React.Dispatch<
|
||||
React.SetStateAction<SegregatedFinishedUploads>
|
||||
>;
|
||||
setUploadFilenames: React.Dispatch<React.SetStateAction<UploadFileNames>>;
|
||||
setHasLivePhotos: React.Dispatch<React.SetStateAction<boolean>>;
|
||||
setUploadProgressView: React.Dispatch<React.SetStateAction<boolean>>;
|
||||
}
|
||||
|
||||
/** The number of uploads to process in parallel. */
|
||||
const maxConcurrentUploads = 4;
|
||||
|
||||
export interface FileWithCollection {
|
||||
localID: number;
|
||||
collectionID: number;
|
||||
isLivePhoto?: boolean;
|
||||
fileOrPath?: File | string;
|
||||
livePhotoAssets?: LivePhotoAssets;
|
||||
}
|
||||
|
||||
export interface LivePhotoAssets {
|
||||
image: File | string;
|
||||
video: File | string;
|
||||
}
|
||||
|
||||
export interface PublicUploadProps {
|
||||
token: string;
|
||||
passwordToken: string;
|
||||
accessedThroughSharedURL: boolean;
|
||||
}
|
||||
|
||||
interface UploadCancelStatus {
|
||||
value: boolean;
|
||||
}
|
||||
|
|
|
@ -26,6 +26,10 @@ import {
|
|||
import { addToCollection } from "services/collectionService";
|
||||
import { parseImageMetadata } from "services/exif";
|
||||
import * as ffmpeg from "services/ffmpeg";
|
||||
import {
|
||||
PublicUploadProps,
|
||||
type LivePhotoAssets,
|
||||
} from "services/upload/uploadManager";
|
||||
import {
|
||||
EnteFile,
|
||||
MetadataFileAttributes,
|
||||
|
@ -35,11 +39,7 @@ import {
|
|||
type FilePublicMagicMetadataProps,
|
||||
} from "types/file";
|
||||
import { EncryptedMagicMetadata } from "types/magicMetadata";
|
||||
import {
|
||||
ParsedExtractedMetadata,
|
||||
PublicUploadProps,
|
||||
type LivePhotoAssets,
|
||||
} from "types/upload";
|
||||
import type { ParsedExtractedMetadata } from "types/metadata";
|
||||
import {
|
||||
getNonEmptyMagicMetadataProps,
|
||||
updateMagicMetadata,
|
||||
|
|
|
@ -14,10 +14,11 @@ import type {
|
|||
import { ensureString } from "@/utils/ensure";
|
||||
import { UPLOAD_RESULT } from "constants/upload";
|
||||
import debounce from "debounce";
|
||||
import uploadManager from "services/upload/uploadManager";
|
||||
import uploadManager, {
|
||||
type FileWithCollection,
|
||||
} from "services/upload/uploadManager";
|
||||
import { Collection } from "types/collection";
|
||||
import { EncryptedEnteFile } from "types/file";
|
||||
import { type FileWithCollection } from "types/upload";
|
||||
import { groupFilesBasedOnCollectionID } from "utils/file";
|
||||
import { isHiddenFile } from "utils/upload";
|
||||
import { removeFromCollection } from "./collectionService";
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Location } from "types/upload";
|
||||
import { Location } from "types/metadata";
|
||||
|
||||
export enum EntityType {
|
||||
LOCATION_TAG = "location",
|
||||
|
|
11
web/apps/photos/src/types/metadata.ts
Normal file
11
web/apps/photos/src/types/metadata.ts
Normal file
|
@ -0,0 +1,11 @@
|
|||
export interface Location {
|
||||
latitude: number;
|
||||
longitude: number;
|
||||
}
|
||||
|
||||
export interface ParsedExtractedMetadata {
|
||||
location: Location;
|
||||
creationTime: number;
|
||||
width: number;
|
||||
height: number;
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
import type { ElectronFile } from "@/next/types/file";
|
||||
|
||||
export interface Location {
|
||||
latitude: number;
|
||||
longitude: number;
|
||||
}
|
||||
|
||||
export interface FileWithCollection {
|
||||
localID: number;
|
||||
collectionID: number;
|
||||
isLivePhoto?: boolean;
|
||||
fileOrPath?: File | string;
|
||||
livePhotoAssets?: LivePhotoAssets;
|
||||
}
|
||||
|
||||
export interface LivePhotoAssets {
|
||||
image: File | string;
|
||||
video: File | string;
|
||||
}
|
||||
|
||||
export interface ParsedExtractedMetadata {
|
||||
location: Location;
|
||||
creationTime: number;
|
||||
width: number;
|
||||
height: number;
|
||||
}
|
||||
|
||||
export interface PublicUploadProps {
|
||||
token: string;
|
||||
passwordToken: string;
|
||||
accessedThroughSharedURL: boolean;
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
import { UPLOAD_RESULT, UPLOAD_STAGES } from "constants/upload";
|
||||
|
||||
export type FileID = number;
|
||||
export type FileName = string;
|
||||
|
||||
export type PercentageUploaded = number;
|
||||
export type UploadFileNames = Map<FileID, FileName>;
|
||||
|
||||
export interface UploadCounter {
|
||||
finished: number;
|
||||
total: number;
|
||||
}
|
||||
|
||||
export interface InProgressUpload {
|
||||
localFileID: FileID;
|
||||
progress: PercentageUploaded;
|
||||
}
|
||||
|
||||
export interface FinishedUpload {
|
||||
localFileID: FileID;
|
||||
result: UPLOAD_RESULT;
|
||||
}
|
||||
|
||||
export type InProgressUploads = Map<FileID, PercentageUploaded>;
|
||||
|
||||
export type FinishedUploads = Map<FileID, UPLOAD_RESULT>;
|
||||
|
||||
export type SegregatedFinishedUploads = Map<UPLOAD_RESULT, FileID[]>;
|
||||
|
||||
export interface ProgressUpdater {
|
||||
setPercentComplete: React.Dispatch<React.SetStateAction<number>>;
|
||||
setUploadCounter: React.Dispatch<React.SetStateAction<UploadCounter>>;
|
||||
setUploadStage: React.Dispatch<React.SetStateAction<UPLOAD_STAGES>>;
|
||||
setInProgressUploads: React.Dispatch<
|
||||
React.SetStateAction<InProgressUpload[]>
|
||||
>;
|
||||
setFinishedUploads: React.Dispatch<
|
||||
React.SetStateAction<SegregatedFinishedUploads>
|
||||
>;
|
||||
setUploadFilenames: React.Dispatch<React.SetStateAction<UploadFileNames>>;
|
||||
setHasLivePhotos: React.Dispatch<React.SetStateAction<boolean>>;
|
||||
setUploadProgressView: React.Dispatch<React.SetStateAction<boolean>>;
|
||||
}
|
Loading…
Add table
Reference in a new issue