π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Inline
Manav Rathi81a83ae7a39f
diff --git a/web/apps/photos/src/components/PhotoFrame.tsx b/web/apps/photos/src/components/PhotoFrame.tsxindex 2596e2c61a..a6955751c8 100644--- a/web/apps/photos/src/components/PhotoFrame.tsx+++ b/web/apps/photos/src/components/PhotoFrame.tsx@@ -19,11 +19,7 @@ import {SelectedState,SetFilesDownloadProgressAttributesCreator,} from "types/gallery";-import {- handleSelectCreator,- updateFileMsrcProps,- updateFileSrcProps,-} from "utils/photoFrame";+import { handleSelectCreator } from "utils/photoFrame";import { PhotoList } from "./PhotoList";import { DedupePhotoList } from "./PhotoList/dedupe";import PreviewCard from "./pages/gallery/PreviewCard";@@ -566,3 +562,81 @@ const PhotoFrame = ({};export default PhotoFrame;++function updateFileMsrcProps(file: EnteFile, url: string) {+ file.w = window.innerWidth;+ file.h = window.innerHeight;+ file.msrc = url;+ file.canForceConvert = false;+ file.isSourceLoaded = false;+ file.conversionFailed = false;+ file.isConverted = false;+ if (file.metadata.fileType === FileType.image) {+ file.src = url;+ } else {+ file.html = `+ <div class = 'pswp-item-container'>+ <img src="${url}"/>+ </div>+ `;+ }+}++async function updateFileSrcProps(+ file: EnteFile,+ srcURLs: SourceURLs,+ enableDownload: boolean,+) {+ const { url, isRenderable, isOriginal } = srcURLs;+ file.w = window.innerWidth;+ file.h = window.innerHeight;+ file.isSourceLoaded =+ file.metadata.fileType === FileType.livePhoto+ ? srcURLs.type === "livePhoto"+ : true;+ file.canForceConvert = srcURLs.canForceConvert;+ file.isConverted = !isOriginal;+ file.conversionFailed = !isRenderable;+ file.srcURLs = srcURLs;+ if (!isRenderable) {+ file.isSourceLoaded = true;+ return;+ }++ if (file.metadata.fileType === FileType.video) {+ file.html = `+ <video controls ${+ !enableDownload && 'controlsList="nodownload"'+ } onContextMenu="return false;">+ <source src="${url}" />+ Your browser does not support the video tag.+ </video>+ `;+ } else if (file.metadata.fileType === FileType.livePhoto) {+ if (srcURLs.type === "normal") {+ file.html = `+ <div class = 'pswp-item-container'>+ <img id = "live-photo-image-${file.id}" src="${url}" onContextMenu="return false;"/>+ </div>+ `;+ } else {+ const { image: imageURL, video: videoURL } =+ url as LivePhotoSourceURL;++ file.html = `+ <div class = 'pswp-item-container'>+ <img id = "live-photo-image-${file.id}" src="${imageURL}" onContextMenu="return false;"/>+ <video id = "live-photo-video-${file.id}" loop muted onContextMenu="return false;">+ <source src="${videoURL}" />+ Your browser does not support the video tag.+ </video>+ </div>+ `;+ }+ } else if (file.metadata.fileType === FileType.image) {+ file.src = url as string;+ } else {+ log.error(`unknown file type - ${file.metadata.fileType}`);+ file.src = url as string;+ }+}diff --git a/web/apps/photos/src/components/PhotoViewer/index.tsx b/web/apps/photos/src/components/PhotoViewer/index.tsxindex db2cbfe79f..1e36ac7e4d 100644--- a/web/apps/photos/src/components/PhotoViewer/index.tsx+++ b/web/apps/photos/src/components/PhotoViewer/index.tsx@@ -55,7 +55,6 @@ import {downloadSingleFile,getFileFromURL,} from "utils/file";-import { pauseVideo, playVideo } from "utils/photoFrame";import { PublicCollectionGalleryContext } from "utils/publicCollectionGallery";import { FileInfo, type FileInfoExif, type FileInfoProps } from "./FileInfo";import ImageEditorOverlay from "./ImageEditorOverlay";@@ -1074,3 +1073,22 @@ const LivePhotoBtnContainer = styled(Paper)`right: 6vh;z-index: 10;`;++export async function playVideo(livePhotoVideo, livePhotoImage) {+ const videoPlaying = !livePhotoVideo.paused;+ if (videoPlaying) return;+ livePhotoVideo.style.opacity = 1;+ livePhotoImage.style.opacity = 0;+ livePhotoVideo.load();+ livePhotoVideo.play().catch(() => {+ pauseVideo(livePhotoVideo, livePhotoImage);+ });+}++export async function pauseVideo(livePhotoVideo, livePhotoImage) {+ const videoPlaying = !livePhotoVideo.paused;+ if (!videoPlaying) return;+ livePhotoVideo.pause();+ livePhotoVideo.style.opacity = 0;+ livePhotoImage.style.opacity = 1;+}diff --git a/web/apps/photos/src/utils/photoFrame/index.ts b/web/apps/photos/src/utils/photoFrame/index.tsindex 1072539157..aff8c83512 100644--- a/web/apps/photos/src/utils/photoFrame/index.ts+++ b/web/apps/photos/src/utils/photoFrame/index.ts@@ -1,108 +1,7 @@-import log from "@/base/log";-import type { LivePhotoSourceURL, SourceURLs } from "@/media/file";-import { EnteFile } from "@/media/file";-import { FileType } from "@/media/file-type";import type { SelectionContext } from "@/new/photos/components/gallery";import type { GalleryBarMode } from "@/new/photos/components/gallery/reducer";import { SetSelectedState } from "types/gallery";-export async function playVideo(livePhotoVideo, livePhotoImage) {- const videoPlaying = !livePhotoVideo.paused;- if (videoPlaying) return;- livePhotoVideo.style.opacity = 1;- livePhotoImage.style.opacity = 0;- livePhotoVideo.load();- livePhotoVideo.play().catch(() => {- pauseVideo(livePhotoVideo, livePhotoImage);- });-}--export async function pauseVideo(livePhotoVideo, livePhotoImage) {- const videoPlaying = !livePhotoVideo.paused;- if (!videoPlaying) return;- livePhotoVideo.pause();- livePhotoVideo.style.opacity = 0;- livePhotoImage.style.opacity = 1;-}--export function updateFileMsrcProps(file: EnteFile, url: string) {- file.w = window.innerWidth;- file.h = window.innerHeight;- file.msrc = url;- file.canForceConvert = false;- file.isSourceLoaded = false;- file.conversionFailed = false;- file.isConverted = false;- if (file.metadata.fileType === FileType.image) {- file.src = url;- } else {- file.html = `- <div class = 'pswp-item-container'>- <img src="${url}"/>- </div>- `;- }-}--export async function updateFileSrcProps(- file: EnteFile,- srcURLs: SourceURLs,- enableDownload: boolean,-) {- const { url, isRenderable, isOriginal } = srcURLs;- file.w = window.innerWidth;- file.h = window.innerHeight;- file.isSourceLoaded =- file.metadata.fileType === FileType.livePhoto- ? srcURLs.type === "livePhoto"- : true;- file.canForceConvert = srcURLs.canForceConvert;- file.isConverted = !isOriginal;- file.conversionFailed = !isRenderable;- file.srcURLs = srcURLs;- if (!isRenderable) {- file.isSourceLoaded = true;- return;- }-- if (file.metadata.fileType === FileType.video) {- file.html = `- <video controls ${- !enableDownload && 'controlsList="nodownload"'- } onContextMenu="return false;">- <source src="${url}" />- Your browser does not support the video tag.- </video>- `;- } else if (file.metadata.fileType === FileType.livePhoto) {- if (srcURLs.type === "normal") {- file.html = `- <div class = 'pswp-item-container'>- <img id = "live-photo-image-${file.id}" src="${url}" onContextMenu="return false;"/>- </div>- `;- } else {- const { image: imageURL, video: videoURL } =- url as LivePhotoSourceURL;-- file.html = `- <div class = 'pswp-item-container'>- <img id = "live-photo-image-${file.id}" src="${imageURL}" onContextMenu="return false;"/>- <video id = "live-photo-video-${file.id}" loop muted onContextMenu="return false;">- <source src="${videoURL}" />- Your browser does not support the video tag.- </video>- </div>- `;- }- } else if (file.metadata.fileType === FileType.image) {- file.src = url as string;- } else {- log.error(`unknown file type - ${file.metadata.fileType}`);- file.src = url as string;- }-}-export const handleSelectCreator =(setSelected: SetSelectedState,