π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
wip checkpoint
Manav Rathic10317ae2ae0
diff --git a/web/apps/photos/src/components/Upload/Uploader.tsx b/web/apps/photos/src/components/Upload/Uploader.tsxindex 68c1620051..65e6b6ed62 100644--- a/web/apps/photos/src/components/Upload/Uploader.tsx+++ b/web/apps/photos/src/components/Upload/Uploader.tsx@@ -3,6 +3,7 @@ import log from "@/base/log";import type { CollectionMapping, Electron, ZipItem } from "@/base/types/ipc";import type { Collection } from "@/media/collection";import { CollectionMappingChoiceDialog } from "@/new/photos/components/CollectionMappingChoiceDialog";+import type { CollectionSelectorAttributes } from "@/new/photos/components/CollectionSelector";import { exportMetadataDirectoryName } from "@/new/photos/services/export";import type {FileAndPath,@@ -35,12 +36,7 @@ import type {} from "services/upload/uploadManager";import uploadManager from "services/upload/uploadManager";import watcher from "services/watch";-import {- SetCollectionSelectorAttributes,- SetCollections,- SetFiles,- SetLoading,-} from "types/gallery";+import { SetCollections, SetFiles, SetLoading } from "types/gallery";import { NotificationAttributes } from "types/Notification";import { getOrCreateAlbum } from "utils/collection";import { PublicCollectionGalleryContext } from "utils/publicCollectionGallery";@@ -63,9 +59,17 @@ enum PICKED_UPLOAD_TYPE {interface Props {syncWithRemote: (force?: boolean, silent?: boolean) => Promise<void>;- closeCollectionSelector?: () => void;closeUploadTypeSelector: () => void;- setCollectionSelectorAttributes?: SetCollectionSelectorAttributes;+ /**+ * Show the collection selector with the given {@link attributes}.+ */+ onOpenCollectionSelector?: (+ attributes: CollectionSelectorAttributes,+ ) => void;+ /**+ * Close the collection selector if it is open.+ */+ onCloseCollectionSelector?: () => void;setCollectionNamerAttributes?: SetCollectionNamerAttributes;setLoading: SetLoading;setShouldDisableDropzone: (value: boolean) => void;@@ -459,17 +463,17 @@ export default function Uploader({showCollectionCreateModal(importSuggestion.rootFolderName);}- props.setCollectionSelectorAttributes({+ props.onOpenCollectionSelector({action: "upload",- callback: uploadFilesToExistingCollection,+ onSelectCollection: uploadFilesToExistingCollection,+ onCreateCollection: showNextModal,onCancel: handleCollectionSelectorCancel,- showNextModal,});})();}, [webFiles, desktopFiles, desktopFilePaths, desktopZipItems]);const preCollectionCreationAction = async () => {- props.closeCollectionSelector?.();+ props.onCloseCollectionSelector?.();props.setShouldDisableDropzone(!uploadManager.shouldAllowNewUpload());setUploadStage(UPLOAD_STAGES.START);setUploadProgressView(true);diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsxindex 3aa8490bed..11d5e1ec87 100644--- a/web/apps/photos/src/pages/gallery.tsx+++ b/web/apps/photos/src/pages/gallery.tsx@@ -4,9 +4,9 @@ import { useIsMobileWidth } from "@/base/hooks";import log from "@/base/log";import type { Collection } from "@/media/collection";import {- CollectionSelectionDialog,- CollectionSelectorAttributes,-} from "@/new/photos/components/CollectionSelectionDialog";+ CollectionSelector,+ type CollectionSelectorAttributes,+} from "@/new/photos/components/CollectionSelector";import {PeopleEmptyState,SearchResultsHeader,@@ -212,10 +212,6 @@ export default function Gallery() {});const [planModalView, setPlanModalView] = useState(false);const [blockingLoad, setBlockingLoad] = useState(false);- const [collectionSelectorAttributes, setCollectionSelectorAttributes] =- useState<CollectionSelectorAttributes>(null);- const [openCollectionSelectionDialog, setOpenCollectionSelectionDialog] =- useState(false);const [collectionNamerAttributes, setCollectionNamerAttributes] =useState<CollectionNamerAttributes>(null);const [collectionNamerView, setCollectionNamerView] = useState(false);@@ -351,6 +347,10 @@ export default function Gallery() {new Set<number>(),);+ const [openCollectionSelector, setOpenCollectionSelector] = useState(false);+ const [collectionSelectorAttributes, setCollectionSelectorAttributes] =+ useState<CollectionSelectorAttributes | undefined>();+const router = useRouter();// Ensure that the keys in local storage are not malformed by verifying that@@ -475,10 +475,6 @@ export default function Gallery() {setEmailList(emailList);}, [user, collections, familyData]);- useEffect(() => {- collectionSelectorAttributes && setOpenCollectionSelectionDialog(true);- }, [collectionSelectorAttributes]);-useEffect(() => {collectionNamerAttributes && setCollectionNamerView(true);}, [collectionNamerAttributes]);@@ -701,7 +697,7 @@ export default function Gallery() {if (sidebarView ||uploadTypeSelectorView ||- openCollectionSelectionDialog ||+ openCollectionSelector ||collectionNamerView ||fixCreationTimeView ||planModalView ||@@ -944,7 +940,7 @@ export default function Gallery() {(ops: COLLECTION_OPS_TYPE) => async (collection: Collection) => {startLoading();try {- setOpenCollectionSelectionDialog(false);+ setOpenCollectionSelector(false);const selectedFiles = getSelectedFiles(selected, filteredData);const toProcessFiles =ops === COLLECTION_OPS_TYPE.REMOVE@@ -1113,7 +1109,12 @@ export default function Gallery() {return <div></div>;}- const handleOpenCollectionSelectionDialog = (attributes: CollectionSelectorAttributes)+ const handleOpenCollectionSelector = (+ attributes: CollectionSelectorAttributes,+ ) => {+ setCollectionSelectorAttributes(attributes);+ setOpenCollectionSelector(true);+ };// `people` will be undefined only when ML is disabled, otherwise it'll be// an empty array (even if people are loading).@@ -1171,9 +1172,9 @@ export default function Gallery() {onHide={setCollectionNamerView.bind(null, false)}attributes={collectionNamerAttributes}/>- <CollectionSelectionDialog- open={openCollectionSelectionDialog}- onClose={() => setOpenCollectionSelectionDialog(false)}+ <CollectionSelector+ open={openCollectionSelector}+ onClose={() => setOpenCollectionSelector(false)}attributes={collectionSelectorAttributes}collectionSummaries={collectionSummaries}collectionForCollectionID={(id) =>@@ -1251,9 +1252,7 @@ export default function Gallery() {null,false,)}- setCollectionSelectorAttributes={- setCollectionSelectorAttributes- }+ onOpenCollectionSelection={handleOpenCollectionSelection}closeCollectionSelector={setOpenCollectionSelectionDialog.bind(null,false,diff --git a/web/packages/new/photos/components/CollectionSelectionDialog.tsx b/web/packages/new/photos/components/CollectionSelector.tsxsimilarity index 93%rename from web/packages/new/photos/components/CollectionSelectionDialog.tsxrename to web/packages/new/photos/components/CollectionSelector.tsxindex 356630813c..6a545e3b80 100644--- a/web/packages/new/photos/components/CollectionSelectionDialog.tsx+++ b/web/packages/new/photos/components/CollectionSelector.tsx@@ -27,20 +27,20 @@ import { t } from "i18next";import React, { useEffect, useState } from "react";import type { DialogVisibilityProps } from "./mui/Dialog";-export type CollectionSelectionAction =+export type CollectionSelectorAction =| "upload"| "add"| "move"| "restore"| "unhide";-export interface CollectionSelectionAttributes {+export interface CollectionSelectorAttributes {/*** The {@link action} modifies the title of the dialog, and also removes* some system collections that don't might not make sense for that* particular action.*/- action: CollectionSelectionAction;+ action: CollectionSelectorAction;/*** Callback invoked when the user selects one the existing collections* listed in the dialog.@@ -64,12 +64,12 @@ export interface CollectionSelectionAttributes {ignoredCollectionID?: number;}-type CollectionSelectionDialogProps = DialogVisibilityProps & {+type CollectionSelectorProps = DialogVisibilityProps & {/**- * The same {@link CollectionSelectionDialog} can be used for different+ * The same {@link CollectionSelector} can be used for different* purposes by customizing the {@link attributes} prop before opening it.*/- attributes: CollectionSelectionAttributes | undefined;+ attributes: CollectionSelectorAttributes | undefined;/*** The collections to list.*/@@ -88,9 +88,7 @@ type CollectionSelectionDialogProps = DialogVisibilityProps & {* A dialog allowing the user to select one of their existing collections or* create a new one.*/-export const CollectionSelectionDialog: React.FC<- CollectionSelectionDialogProps-> = ({+export const CollectionSelector: React.FC<CollectionSelectorProps> = ({open,onClose,attributes,@@ -202,7 +200,7 @@ const Dialog_ = styled(Dialog)(({ theme }) => ({},}));-const dialogTitleForAction = (action: CollectionSelectionAction) => {+const dialogTitleForAction = (action: CollectionSelectorAction) => {switch (action) {case "upload":return t("upload_to_album");