Skip to content

armgit / ente

Public Imported from GitHub
0

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

Rename

Manav Rathi85397732c81b
diff --git a/web/apps/photos/src/components/FixCreationTime.tsx b/web/apps/photos/src/components/FixCreationTime.tsx
index d427b52ad5..4735aa7722 100644
--- a/web/apps/photos/src/components/FixCreationTime.tsx
+++ b/web/apps/photos/src/components/FixCreationTime.tsx
@@ -1,7 +1,7 @@
import log from "@/base/log";
import {
decryptPublicMagicMetadata,
- getUICreationDate,
+ fileCreationPhotoDate,
updateRemotePublicMagicMetadata,
type ParsedMetadataDate,
} from "@/media/file-metadata";
@@ -352,11 +352,11 @@ const updateEnteFileDate = async (
if (!newDate) return;
- const existingUIDate = getUICreationDate(
+ const existingDate = fileCreationPhotoDate(
enteFile,
await decryptPublicMagicMetadata(enteFile),
);
- if (newDate.timestamp == existingUIDate.getTime()) return;
+ if (newDate.timestamp == existingDate.getTime()) return;
await updateRemotePublicMagicMetadata(enteFile, {
dateTime: newDate.dateTime,
diff --git a/web/apps/photos/src/components/PhotoViewer/FileInfo/index.tsx b/web/apps/photos/src/components/PhotoViewer/FileInfo/index.tsx
index 7ae609c149..f36e87b7dd 100644
--- a/web/apps/photos/src/components/PhotoViewer/FileInfo/index.tsx
+++ b/web/apps/photos/src/components/PhotoViewer/FileInfo/index.tsx
@@ -6,8 +6,8 @@ import log from "@/base/log";
import type { Location } from "@/base/types";
import type { ParsedMetadata } from "@/media/file-metadata";
import {
+ fileCreationPhotoDate,
fileLocation,
- getUICreationDate,
updateRemotePublicMagicMetadata,
type ParsedMetadataDate,
} from "@/media/file-metadata";
@@ -362,7 +362,7 @@ export const CreationTime: React.FC<CreationTimeProps> = ({
const closeEditMode = () => setIsInEditMode(false);
const publicMagicMetadata = getPublicMagicMetadataSync(enteFile);
- const originalDate = getUICreationDate(enteFile, publicMagicMetadata);
+ const originalDate = fileCreationPhotoDate(enteFile, publicMagicMetadata);
const saveEdits = async (pickedTime: ParsedMetadataDate) => {
try {
diff --git a/web/apps/photos/src/services/export/index.ts b/web/apps/photos/src/services/export/index.ts
index 261d3d5e33..c65b7ceadc 100644
--- a/web/apps/photos/src/services/export/index.ts
+++ b/web/apps/photos/src/services/export/index.ts
@@ -1,8 +1,8 @@
import { ensureElectron } from "@/base/electron";
import log from "@/base/log";
import {
+ fileCreationPhotoDate,
fileLocation,
- getUICreationDate,
type Metadata,
} from "@/media/file-metadata";
import { FileType } from "@/media/file-type";
@@ -1422,7 +1422,7 @@ const getGoogleLikeMetadataFile = (
creationTime: {
timestamp: creationTime,
formatted: dateTimeFormatter.format(
- getUICreationDate(file, file.pubMagicMetadata?.data),
+ fileCreationPhotoDate(file, file.pubMagicMetadata?.data),
),
},
modificationTime: {
diff --git a/web/packages/media/file-metadata.ts b/web/packages/media/file-metadata.ts
index 7741030cf5..507f023c71 100644
--- a/web/packages/media/file-metadata.ts
+++ b/web/packages/media/file-metadata.ts
@@ -329,15 +329,16 @@ const withoutNullAndUndefinedValues = (o: object) =>
);
/**
- * Return the file's creation date in a form suitable for using in the UI.
+ * Return the file's creation date as a Date in the hypothetical "timezone of
+ * the photo".
*
- * For all the details and nuance, see {@link toUIDate}.
+ * For all the details and nuance, see {@link createPhotoDate}.
*/
-export const getUICreationDate = (
+export const fileCreationPhotoDate = (
enteFile: EnteFile,
publicMagicMetadata: PublicMagicMetadata | undefined,
) =>
- toUIDate(
+ createPhotoDate(
publicMagicMetadata?.dateTime ??
publicMagicMetadata?.editedTime ??
enteFile.metadata.creationTime,
@@ -726,9 +727,9 @@ export const parseMetadataDate = (
const dropLast = (s: string) => (s ? s.substring(0, s.length - 1) : s);
/**
- * Return a date that can be used on the UI by constructing it from a
- * {@link ParsedMetadataDate}, or its {@link dateTime} component, or a UTC epoch
- * timestamp.
+ * Return a date that can be used on the represent a photo on the UI, by
+ * constructing it from a {@link ParsedMetadataDate}, or its {@link dateTime}
+ * component, or a UTC epoch timestamp.
*
* These dates are all hypothetically in the timezone of the place where the
* photo was taken. Different photos might've been taken in different timezones,
@@ -747,7 +748,9 @@ const dropLast = (s: string) => (s ? s.substring(0, s.length - 1) : s);
*
* See also: [Note: Photos are always in local date/time].
*/
-export const toUIDate = (dateLike: ParsedMetadataDate | string | number) => {
+export const createPhotoDate = (
+ dateLike: ParsedMetadataDate | string | number,
+) => {
switch (typeof dateLike) {
case "object":
// A ISO 8601 string without a timezone. The Date constructor will
diff --git a/web/packages/new/photos/services/search/worker.ts b/web/packages/new/photos/services/search/worker.ts
index 51040c3ae7..cdfea0b22d 100644
--- a/web/packages/new/photos/services/search/worker.ts
+++ b/web/packages/new/photos/services/search/worker.ts
@@ -2,7 +2,7 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */
/* eslint-disable @typescript-eslint/prefer-includes */
/* eslint-disable @typescript-eslint/no-unnecessary-condition */
-import { fileLocation, getUICreationDate } from "@/media/file-metadata";
+import { fileCreationPhotoDate, fileLocation } from "@/media/file-metadata";
import type { EnteFile } from "@/new/photos/types/file";
import { wait } from "@/utils/promise";
import { nullToUndefined } from "@/utils/transform";
@@ -163,7 +163,7 @@ const isMatch = (file: EnteFile, query: SearchQuery) => {
if (query?.date) {
return isDateComponentsMatch(
query.date,
- getUICreationDate(file, getPublicMagicMetadataSync(file)),
+ fileCreationPhotoDate(file, getPublicMagicMetadataSync(file)),
);
}