Skip to content

armgit / ente

Public Imported from GitHub
0

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

Conv

Manav Rathica748f731e69
diff --git a/web/apps/photos/src/components/Collections/CollectionShare.tsx b/web/apps/photos/src/components/Collections/CollectionShare.tsx
index 14a965a1f9..da18fe3ce5 100644
--- a/web/apps/photos/src/components/Collections/CollectionShare.tsx
+++ b/web/apps/photos/src/components/Collections/CollectionShare.tsx
@@ -54,6 +54,7 @@ import type {
import { type CollectionUser } from "ente-media/collection";
import { PublicLinkCreated } from "ente-new/photos/components/share/PublicLinkCreated";
import { avatarTextColor } from "ente-new/photos/services/avatar";
+import { deleteShareURL } from "ente-new/photos/services/collection";
import type { CollectionSummary } from "ente-new/photos/services/collection/ui";
import { usePhotosAppContext } from "ente-new/photos/types/context";
import { CustomError, parseSharingErrorCodes } from "ente-shared/error";
@@ -65,7 +66,6 @@ import React, { useContext, useEffect, useMemo, useRef, useState } from "react";
import { Trans } from "react-i18next";
import {
createShareableURL,
- deleteShareableURL,
shareCollection,
unshareCollection,
updateShareableURL,
@@ -1222,16 +1222,16 @@ const ManagePublicShareOptions: React.FC<ManagePublicShareOptionsProps> = ({
galleryContext.setBlockingLoad(false);
}
};
- const disablePublicSharing = async () => {
+ const handleRemovePublicLink = async () => {
try {
galleryContext.setBlockingLoad(true);
- await deleteShareableURL(collection);
+ await deleteShareURL(collection.id);
setPublicShareProp(null);
galleryContext.syncWithRemote(false, true);
onClose();
} catch (e) {
- const errorMessage = handleSharingErrors(e);
- setSharableLinkError(errorMessage);
+ log.error("Failed to remove public link", e);
+ setSharableLinkError(t("generic_error"));
} finally {
galleryContext.setBlockingLoad(false);
}
@@ -1293,7 +1293,7 @@ const ManagePublicShareOptions: React.FC<ManagePublicShareOptionsProps> = ({
<RowButton
color="critical"
startIcon={<RemoveCircleOutlineIcon />}
- onClick={disablePublicSharing}
+ onClick={handleRemovePublicLink}
label={t("remove_link")}
/>
</RowButtonGroup>
diff --git a/web/apps/photos/src/services/collectionService.ts b/web/apps/photos/src/services/collectionService.ts
index 5394dd1678..c85a1a3eed 100644
--- a/web/apps/photos/src/services/collectionService.ts
+++ b/web/apps/photos/src/services/collectionService.ts
@@ -571,24 +571,6 @@ export const createShareableURL = async (collection: Collection) => {
}
};
-export const deleteShareableURL = async (collection: Collection) => {
- try {
- const token = getToken();
- if (!token) {
- return null;
- }
- await HTTPService.delete(
- await apiURL(`/collections/share-url/${collection.id}`),
- null,
- null,
- { "X-Auth-Token": token },
- );
- } catch (e) {
- log.error("deleteShareableURL failed ", e);
- throw e;
- }
-};
-
export const updateShareableURL = async (
request: UpdatePublicURL,
): Promise<PublicURL> => {
diff --git a/web/packages/new/photos/services/collection.ts b/web/packages/new/photos/services/collection.ts
index de486224ce..d809f05d59 100644
--- a/web/packages/new/photos/services/collection.ts
+++ b/web/packages/new/photos/services/collection.ts
@@ -263,3 +263,16 @@ export const deleteFromTrash = async (fileIDs: number[]) => {
);
}
};
+
+/**
+ * Delete the public link for the collection with given {@link collectionID}.
+ *
+ * Does not modify local state.
+ */
+export const deleteShareURL = async (collectionID: number) =>
+ ensureOk(
+ await fetch(await apiURL(`/collections/share-url/${collectionID}`), {
+ method: "DELETE",
+ headers: await authenticatedRequestHeaders(),
+ }),
+ );