Skip to content

armgit / ente

Public Imported from GitHub
0

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

feat: check if files are eligible for cast

httpjamesmdbbcd2b6bbc0
diff --git a/apps/cast/src/pages/slideshow.tsx b/apps/cast/src/pages/slideshow.tsx
index 6c30cf8184..becf4ad2dd 100644
--- a/apps/cast/src/pages/slideshow.tsx
+++ b/apps/cast/src/pages/slideshow.tsx
@@ -1,11 +1,12 @@
// import { Inter } from 'next/font/google';
import PairedSuccessfullyOverlay from 'components/PairedSuccessfullyOverlay';
+import { FILE_TYPE } from 'constants/file';
import { useRouter } from 'next/router';
import { useEffect, useState } from 'react';
import { syncCollections } from 'services/collectionService';
import { syncFiles } from 'services/fileService';
import { EnteFile } from 'types/file';
-import { downloadFileAsBlob } from 'utils/file';
+import { downloadFileAsBlob, isRawFileFromFileName } from 'utils/file';
export default function Slideshow() {
const [collectionFiles, setCollectionFiles] = useState<EnteFile[]>([]);
@@ -32,13 +33,34 @@ export default function Slideshow() {
file.collectionID === Number(requestedCollectionID)
);
- setCollectionFiles(collectionFiles);
+ setCollectionFiles(
+ collectionFiles.filter((file) =>
+ isFileEligibleForCast(file)
+ )
+ );
}
} catch {
router.push('/');
}
};
+ const isFileEligibleForCast = (file: EnteFile) => {
+ const fileType = file.metadata.fileType;
+ if (fileType !== FILE_TYPE.IMAGE && fileType !== FILE_TYPE.VIDEO) {
+ return false;
+ }
+
+ const name = file.metadata.title;
+
+ if (fileType === FILE_TYPE.IMAGE) {
+ if (isRawFileFromFileName(name)) {
+ return false;
+ }
+ }
+
+ return true;
+ };
+
const router = useRouter();
useEffect(() => {
@@ -73,13 +95,17 @@ export default function Slideshow() {
const [renderableFileURL, setRenderableFileURL] = useState<string>('');
const getRenderableFileURL = async () => {
- const blob = await downloadFileAsBlob(currentFile as EnteFile);
-
- const url = URL.createObjectURL(blob);
+ try {
+ const blob = await downloadFileAsBlob(currentFile as EnteFile);
- setRenderableFileURL(url);
+ const url = URL.createObjectURL(blob);
- setLoading(false);
+ setRenderableFileURL(url);
+ } catch (e) {
+ return;
+ } finally {
+ setLoading(false);
+ }
};
useEffect(() => {