Skip to content

armgit / ente

Public Imported from GitHub
0

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

Forward

Manav Rathibdb5f5894e71
diff --git a/web/apps/photos/src/components/Collections/CollectionShare.tsx b/web/apps/photos/src/components/Collections/CollectionShare.tsx
index 6d2d9ac349..d33e2e8a4c 100644
--- a/web/apps/photos/src/components/Collections/CollectionShare.tsx
+++ b/web/apps/photos/src/components/Collections/CollectionShare.tsx
@@ -87,9 +87,10 @@ import React, {
import { Trans } from "react-i18next";
import { z } from "zod/v4";
-type CollectionShareProps = ModalVisibilityProps & {
+export type CollectionShareProps = ModalVisibilityProps & {
collection: Collection;
collectionSummary: CollectionSummary;
+ setBlockingLoad: (value: boolean) => void;
/**
* Called when an operation in the share menu requires a full remote pull.
*/
@@ -101,6 +102,7 @@ export const CollectionShare: React.FC<CollectionShareProps> = ({
onClose,
collection,
collectionSummary,
+ setBlockingLoad,
onRemotePull,
}) => {
const { onGenericError } = useBaseContext();
@@ -162,7 +164,11 @@ export const CollectionShare: React.FC<CollectionShareProps> = ({
/>
<PublicShare
onRootClose={onClose}
- {...{ collection, onRemotePull }}
+ {...{
+ collection,
+ setBlockingLoad,
+ onRemotePull,
+ }}
/>
</>
)}
@@ -977,12 +983,13 @@ const ManageParticipant: React.FC<ManageParticipantProps> = ({
type PublicShareProps = { onRootClose: () => void } & Pick<
CollectionShareProps,
- "collection" | "onRemotePull"
+ "collection" | "setBlockingLoad" | "onRemotePull"
>;
const PublicShare: React.FC<PublicShareProps> = ({
collection,
onRootClose,
+ setBlockingLoad,
onRemotePull,
}) => {
const [publicShareUrl, setPublicShareUrl] = useState<string>(null);
@@ -1022,6 +1029,7 @@ const PublicShare: React.FC<PublicShareProps> = ({
publicURL,
setPublicURL,
publicShareUrl,
+ setBlockingLoad,
onRemotePull,
}}
/>
@@ -1125,7 +1133,10 @@ type ManagePublicShareProps = {
publicURL: PublicURL;
setPublicURL: (publicURL: PublicURL | undefined) => void;
publicShareUrl: string;
-} & Pick<CollectionShareProps, "collection" | "onRemotePull">;
+} & Pick<
+ CollectionShareProps,
+ "collection" | "setBlockingLoad" | "onRemotePull"
+>;
const ManagePublicShare: React.FC<ManagePublicShareProps> = ({
onRootClose,
@@ -1133,6 +1144,7 @@ const ManagePublicShare: React.FC<ManagePublicShareProps> = ({
publicURL,
setPublicURL,
publicShareUrl,
+ setBlockingLoad,
onRemotePull,
}) => {
const {
@@ -1188,6 +1200,7 @@ const ManagePublicShare: React.FC<ManagePublicShareProps> = ({
publicURL,
publicShareUrl,
setPublicURL,
+ setBlockingLoad,
onRemotePull,
}}
/>
@@ -1204,7 +1217,10 @@ type ManagePublicShareOptionsProps = ModalVisibilityProps & {
publicURL: PublicURL;
setPublicURL: (publicURL: PublicURL | undefined) => void;
publicShareUrl: string;
-} & Pick<CollectionShareProps, "collection" | "onRemotePull">;
+} & Pick<
+ CollectionShareProps,
+ "collection" | "setBlockingLoad" | "onRemotePull"
+ >;
const ManagePublicShareOptions: React.FC<ManagePublicShareOptionsProps> = ({
open,
@@ -1214,10 +1230,9 @@ const ManagePublicShareOptions: React.FC<ManagePublicShareOptionsProps> = ({
publicURL,
setPublicURL,
publicShareUrl,
+ setBlockingLoad,
onRemotePull,
}) => {
- const galleryContext = useContext(GalleryContext);
-
const [sharableLinkError, setSharableLinkError] = useState(null);
const [copied, handleCopyLink] = useClipboardCopy(publicShareUrl);
@@ -1231,19 +1246,19 @@ const ManagePublicShareOptions: React.FC<ManagePublicShareOptionsProps> = ({
updates: UpdatePublicURLAttributes,
) => {
try {
- galleryContext.setBlockingLoad(true);
+ setBlockingLoad(true);
setPublicURL(await updatePublicURL(collection.id, updates));
void onRemotePull({ silent: true });
} catch (e) {
log.error("Could not update public link", e);
setSharableLinkError(t("generic_error"));
} finally {
- galleryContext.setBlockingLoad(false);
+ setBlockingLoad(false);
}
};
const handleRemovePublicLink = async () => {
try {
- galleryContext.setBlockingLoad(true);
+ setBlockingLoad(true);
await deleteShareURL(collection.id);
setPublicURL(undefined);
void onRemotePull({ silent: true });
@@ -1252,7 +1267,7 @@ const ManagePublicShareOptions: React.FC<ManagePublicShareOptionsProps> = ({
log.error("Failed to remove public link", e);
setSharableLinkError(t("generic_error"));
} finally {
- galleryContext.setBlockingLoad(false);
+ setBlockingLoad(false);
}
};
diff --git a/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx b/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx
index 4edfd191c6..f5a20dd98e 100644
--- a/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx
+++ b/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx
@@ -1,5 +1,8 @@
import { AllAlbums } from "components/Collections/AllAlbums";
-import { CollectionShare } from "components/Collections/CollectionShare";
+import {
+ CollectionShare,
+ type CollectionShareProps,
+} from "components/Collections/CollectionShare";
import { TimeStampListItem } from "components/FileList";
import { useModalVisibility } from "ente-base/components/utils/modal";
import type { Collection } from "ente-media/collection";
@@ -54,7 +57,8 @@ type GalleryBarAndListHeaderProps = Omit<
} & Pick<
CollectionHeaderProps,
"setFilesDownloadProgressAttributesCreator" | "onRemotePull"
- >;
+ > &
+ Pick<CollectionShareProps, "setBlockingLoad">;
/**
* The gallery bar, the header for the list items, and state for any associated
@@ -84,6 +88,7 @@ export const GalleryBarAndListHeader: React.FC<
activeCollection,
activeCollectionID,
setActiveCollectionID,
+ setBlockingLoad,
hiddenCollectionSummaries,
people,
activePerson,
@@ -224,7 +229,7 @@ export const GalleryBarAndListHeader: React.FC<
activeCollectionID,
)}
collection={activeCollection}
- {...{ onRemotePull }}
+ {...{ setBlockingLoad, onRemotePull }}
/>
<AlbumCastDialog
{...collectionCastVisibilityProps}
diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsx
index 246ae7dd57..bcd76f8430 100644
--- a/web/apps/photos/src/pages/gallery.tsx
+++ b/web/apps/photos/src/pages/gallery.tsx
@@ -131,7 +131,6 @@ import { getSelectedFiles, handleFileOp, type FileOp } from "utils/file";
const defaultGalleryContext: GalleryContextType = {
setActiveCollectionID: () => null,
- setBlockingLoad: () => null,
photoListHeader: null,
user: null,
userIDToEmailMap: null,
@@ -882,7 +881,6 @@ const Page: React.FC = () => {
value={{
...defaultGalleryContext,
setActiveCollectionID: handleShowCollectionSummary,
- setBlockingLoad,
photoListHeader,
user,
// TODO(RE): Rename
@@ -1020,6 +1018,7 @@ const Page: React.FC = () => {
: undefined) ?? []
}
onChangeMode={handleChangeBarMode}
+ setBlockingLoad={setBlockingLoad}
setActiveCollectionID={handleShowCollectionSummary}
onRemotePull={remotePull}
onSelectPerson={handleSelectPerson}
diff --git a/web/apps/photos/src/types/gallery/index.ts b/web/apps/photos/src/types/gallery/index.ts
index 188a0a60de..f68a2f8871 100644
--- a/web/apps/photos/src/types/gallery/index.ts
+++ b/web/apps/photos/src/types/gallery/index.ts
@@ -40,7 +40,6 @@ export interface MergedSourceURL {
export interface GalleryContextType {
setActiveCollectionID: (collectionID: number) => void;
- setBlockingLoad: (value: boolean) => void;
photoListHeader: TimeStampListItem;
user: User;
userIDToEmailMap: Map<number, string>;