Skip to content

armgit / ente

Public Imported from GitHub
0

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

Localize gallery type suppressions

Manav Rathi01a09662f4a7
diff --git a/web/apps/albums/src/public-album/upload/pipeline/upload-service.ts b/web/apps/albums/src/public-album/upload/pipeline/upload-service.ts
index 478618f1ec..e2cdfeacdc 100644
--- a/web/apps/albums/src/public-album/upload/pipeline/upload-service.ts
+++ b/web/apps/albums/src/public-album/upload/pipeline/upload-service.ts
@@ -590,7 +590,6 @@ const readLivePhotoDetails = async ({ image, video }: LivePhotoAssets) => {
const readImageOrVideoDetails = async (uploadItem: UploadItem) => {
const { stream, fileSize, lastModifiedMs } = readUploadItem(uploadItem);
- // @ts-ignore
const fileTypeInfo = await detectFileTypeInfoFromChunk(async () => {
const reader = stream.getReader();
const chunk = (await reader.read()).value;
diff --git a/web/packages/gallery/components/FileInfo.tsx b/web/packages/gallery/components/FileInfo.tsx
index 39449fc383..fb79ddceb9 100644
--- a/web/packages/gallery/components/FileInfo.tsx
+++ b/web/packages/gallery/components/FileInfo.tsx
@@ -1,4 +1,3 @@
-/* eslint-disable @typescript-eslint/ban-ts-comment */
// TODO: Split this file to deal with the ente-new/photos imports.
import CalendarTodayIcon from "@mui/icons-material/CalendarToday";
@@ -986,12 +985,9 @@ const MapBox: React.FC<MapBoxProps> = ({ location, mapEnabled }) => {
const position: L.LatLngTuple = [location.latitude, location.longitude];
if (!mapRef.current) {
- // @ts-ignore
const map = leaflet.map(mapContainer).setView(position, zoom);
map.attributionControl.setPrefix(leafletAttributionPrefix);
- // @ts-ignore
leaflet.tileLayer(urlTemplate, { attribution }).addTo(map);
- // @ts-ignore
markerRef.current = leaflet.marker(position).addTo(map);
mapRef.current = map;
} else {
diff --git a/web/packages/gallery/services/upload/upload-service.ts b/web/packages/gallery/services/upload/upload-service.ts
index 74e6ac077d..3dc060bd4a 100644
--- a/web/packages/gallery/services/upload/upload-service.ts
+++ b/web/packages/gallery/services/upload/upload-service.ts
@@ -1,6 +1,3 @@
-// TODO: Audit this file
-/* eslint-disable @typescript-eslint/ban-ts-comment */
-
import type { BytesOrB64 } from "ente-base/crypto/types";
import {
streamEncryptionChunkOverhead,
@@ -729,10 +726,8 @@ const readAssetDetails = async ({
uploadItem,
}: UploadAsset): Promise<ReadAssetDetailsResult> =>
isLivePhoto
- ? // @ts-ignore
- readLivePhotoDetails(livePhotoAssets)
- : // @ts-ignore
- readImageOrVideoDetails(uploadItem);
+ ? readLivePhotoDetails(livePhotoAssets!)
+ : readImageOrVideoDetails(uploadItem!);
const readLivePhotoDetails = async ({ image, video }: LivePhotoAssets) => {
const img = await readImageOrVideoDetails(image);
@@ -752,7 +747,6 @@ const readImageOrVideoDetails = async (uploadItem: UploadItem) => {
const { stream, fileSize, lastModifiedMs } =
await readUploadItem(uploadItem);
- // @ts-ignore
const fileTypeInfo = await detectFileTypeInfoFromChunk(async () => {
const reader = stream.getReader();
const chunk = (await reader.read()).value;
@@ -789,8 +783,7 @@ const extractAssetMetadata = async (
): Promise<ExtractAssetMetadataResult> =>
isLivePhoto
? await extractLivePhotoMetadata(
- // @ts-ignore
- livePhotoAssets,
+ livePhotoAssets!,
pathPrefix,
lastModifiedMs,
collectionID,
@@ -798,8 +791,7 @@ const extractAssetMetadata = async (
worker,
)
: await extractImageOrVideoMetadata(
- // @ts-ignore
- uploadItem,
+ uploadItem!,
pathPrefix,
externalParsedMetadata,
fileType,
@@ -1032,10 +1024,8 @@ const readAsset = async (
{ isLivePhoto, uploadItem, livePhotoAssets }: UploadAsset,
): Promise<ThumbnailedFile> =>
isLivePhoto
- ? // @ts-ignore
- await readLivePhoto(livePhotoAssets, fileTypeInfo)
- : // @ts-ignore
- await readImageOrVideo(uploadItem, fileTypeInfo);
+ ? await readLivePhoto(livePhotoAssets!, fileTypeInfo)
+ : await readImageOrVideo(uploadItem!, fileTypeInfo);
const readLivePhoto = async (
livePhotoAssets: LivePhotoAssets,
diff --git a/web/packages/gallery/utils/detect-type.ts b/web/packages/gallery/utils/detect-type.ts
index 2bd3d63739..7dfd5268e1 100644
--- a/web/packages/gallery/utils/detect-type.ts
+++ b/web/packages/gallery/utils/detect-type.ts
@@ -11,12 +11,12 @@ export const detectFileTypeInfo = async (file: File): Promise<FileTypeInfo> =>
detectFileTypeInfoFromChunk(() => readInitialChunkOfFile(file), file.name);
export const detectFileTypeInfoFromChunk = async (
- readInitialChunk: () => Promise<Uint8Array>,
+ readInitialChunk: () => Promise<Uint8Array | undefined>,
fileNameOrPath: string,
): Promise<FileTypeInfo> => {
try {
const typeResult = await detectFileTypeFromBuffer(
- await readInitialChunk(),
+ (await readInitialChunk())!,
);
const mimeType = typeResult.mime;