Skip to content

armgit / ente

Public Imported from GitHub
0

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

Conv

Manav Rathi0931e590a94c
diff --git a/web/apps/photos/src/components/Collections/CollectionHeader.tsx b/web/apps/photos/src/components/Collections/CollectionHeader.tsx
index 11062597ee..e6330ecc81 100644
--- a/web/apps/photos/src/components/Collections/CollectionHeader.tsx
+++ b/web/apps/photos/src/components/Collections/CollectionHeader.tsx
@@ -39,6 +39,7 @@ import {
ALL_SECTION,
HIDDEN_ITEMS_SECTION,
isHiddenCollection,
+ leaveSharedCollection,
} from "ente-new/photos/services/collection";
import type {
CollectionSummary,
@@ -260,7 +261,7 @@ const CollectionOptions: React.FC<CollectionHeaderProps> = ({
changeCollectionVisibility(activeCollection, ItemVisibility.visible),
);
- const confirmLeaveSharedAlbum = () => {
+ const confirmLeaveSharedAlbum = () =>
showMiniDialog({
title: t("leave_shared_album_title"),
message: t("leave_shared_album_message"),
@@ -270,10 +271,10 @@ const CollectionOptions: React.FC<CollectionHeaderProps> = ({
action: leaveSharedAlbum,
},
});
- };
+
const leaveSharedAlbum = wrap(async () => {
- await CollectionAPI.leaveSharedAlbum(activeCollection.id);
+ await leaveSharedCollection(activeCollection.id);
setActiveCollectionID(ALL_SECTION);
});
diff --git a/web/apps/photos/src/services/collectionService.ts b/web/apps/photos/src/services/collectionService.ts
index 7209db5cc1..e0e568434f 100644
--- a/web/apps/photos/src/services/collectionService.ts
+++ b/web/apps/photos/src/services/collectionService.ts
@@ -334,22 +334,6 @@ export const deleteCollection = async (
}
};
-export const leaveSharedAlbum = async (collectionID: number) => {
- try {
- const token = getToken();
-
- await HTTPService.post(
- await apiURL(`/collections/leave/${collectionID}`),
- null,
- null,
- { "X-Auth-Token": token },
- );
- } catch (e) {
- log.error("leave shared album failed ", e);
- throw e;
- }
-};
-
export const updateCollectionMagicMetadata = async (
collection: Collection,
updatedMagicMetadata: CollectionMagicMetadata,
diff --git a/web/packages/new/photos/services/collection.ts b/web/packages/new/photos/services/collection.ts
index 17bdf640bc..dcbe72b9b0 100644
--- a/web/packages/new/photos/services/collection.ts
+++ b/web/packages/new/photos/services/collection.ts
@@ -304,7 +304,7 @@ export const shareCollection = async (
/**
* Delete the public link for the collection with given {@link collectionID}.
*
- * Does not modify local state.
+ * Remote only, does not modify local state.
*/
export const deleteShareURL = async (collectionID: number) =>
ensureOk(
@@ -313,3 +313,18 @@ export const deleteShareURL = async (collectionID: number) =>
headers: await authenticatedRequestHeaders(),
}),
);
+
+/**
+ * Leave a collection which had previously been shared with the user.
+ *
+ * Remote only, does not modify local state.
+ *
+ * @param collectionID The ID of the shared collection to leave.
+ */
+export const leaveSharedCollection = async (collectionID: number) =>
+ ensureOk(
+ await fetch(await apiURL(`/collections/leave/${collectionID}`), {
+ method: "POST",
+ headers: await authenticatedRequestHeaders(),
+ }),
+ );