Skip to content

armgit / ente

Public Imported from GitHub
0

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

Add reactions API and unlike album selector modal

Anand Baburajanb5ac36941a89
diff --git a/web/apps/photos/src/components/Collections/CollectionShare.tsx b/web/apps/photos/src/components/Collections/CollectionShare.tsx
index 83db4aaa25..c529828375 100644
--- a/web/apps/photos/src/components/Collections/CollectionShare.tsx
+++ b/web/apps/photos/src/components/Collections/CollectionShare.tsx
@@ -2277,7 +2277,8 @@ const commentPermissionOptions: {
value: "signed_in",
label: "Signed-in only",
caption: "Signed-in",
- description: "Only people signed in to Ente can comment on this memory.",
+ description:
+ "Only people signed in to Ente can comment on this memory.",
},
{
value: "no_one",
@@ -2294,13 +2295,12 @@ const getCommentPermissionCaption = (permission: CommentPermission) => {
const ManageComments: React.FC<ManagePublicLinkSettingDrawerProps> = ({
onRootClose,
- publicURL: _publicURL,
- onUpdate: _onUpdate,
+ // TODO: Use these when backend is ready
+ publicURL: _publicURL, // eslint-disable-line @typescript-eslint/no-unused-vars
+ onUpdate: _onUpdate, // eslint-disable-line @typescript-eslint/no-unused-vars
}) => {
- const {
- show: showCommentOptions,
- props: commentOptionsVisibilityProps,
- } = useModalVisibility();
+ const { show: showCommentOptions, props: commentOptionsVisibilityProps } =
+ useModalVisibility();
// TODO: Replace with actual state from publicURL when backend is ready
const [viewComments, setViewComments] = useState(true);
diff --git a/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx b/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx
index e09c251d7f..4ddd9dd2b4 100644
--- a/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx
+++ b/web/apps/photos/src/components/Collections/GalleryBarAndListHeader.tsx
@@ -49,7 +49,7 @@ type GalleryBarAndListHeaderProps = Omit<
*/
shouldHide: boolean;
barCollectionSummaries: CollectionSummaries;
- activeCollection: Collection;
+ activeCollection: Collection | undefined;
setActiveCollectionID: (collectionID: number) => void;
setFileListHeader: (header: FileListHeaderOrFooter) => void;
saveGroups: SaveGroup[];
@@ -110,10 +110,8 @@ export const GalleryBarAndListHeader: React.FC<
useModalVisibility();
const { show: showCollectionCast, props: collectionCastVisibilityProps } =
useModalVisibility();
- const {
- show: showCollectionFeed,
- props: collectionFeedVisibilityProps,
- } = useModalVisibility();
+ const { show: showCollectionFeed, props: collectionFeedVisibilityProps } =
+ useModalVisibility();
const [collectionsSortBy, setCollectionsSortBy] =
useCollectionsSortByLocalState("updation-time-desc");
@@ -147,7 +145,7 @@ export const GalleryBarAndListHeader: React.FC<
setFileListHeader({
component:
- mode != "people" ? (
+ mode != "people" && activeCollection ? (
<CollectionHeader
{...{
activeCollection,
@@ -178,6 +176,7 @@ export const GalleryBarAndListHeader: React.FC<
shouldHide,
mode,
toShowCollectionSummaries,
+ activeCollection,
activeCollectionID,
isActiveCollectionDownloadInProgress,
activePerson,
@@ -224,29 +223,33 @@ export const GalleryBarAndListHeader: React.FC<
isInHiddenSection={mode == "hidden-albums"}
onRemotePull={onRemotePull}
/>
- <CollectionShare
- {...collectionShareVisibilityProps}
- collectionSummary={
- toShowCollectionSummaries.get(activeCollectionID!)!
- }
- collection={activeCollection}
- {...{
- user,
- emailByUserID,
- shareSuggestionEmails,
- setBlockingLoad,
- onRemotePull,
- }}
- />
- <AlbumCastDialog
- {...collectionCastVisibilityProps}
- collection={activeCollection}
- />
- <FeedSidebar
- {...collectionFeedVisibilityProps}
- albumName={activeCollection?.name ?? ""}
- files={files}
- />
+ {activeCollection && (
+ <>
+ <CollectionShare
+ {...collectionShareVisibilityProps}
+ collectionSummary={
+ toShowCollectionSummaries.get(activeCollectionID!)!
+ }
+ collection={activeCollection}
+ {...{
+ user,
+ emailByUserID,
+ shareSuggestionEmails,
+ setBlockingLoad,
+ onRemotePull,
+ }}
+ />
+ <AlbumCastDialog
+ {...collectionCastVisibilityProps}
+ collection={activeCollection}
+ />
+ <FeedSidebar
+ {...collectionFeedVisibilityProps}
+ albumName={activeCollection.name}
+ files={files}
+ />
+ </>
+ )}
</>
);
};
diff --git a/web/apps/photos/src/styles/photoswipe.css b/web/apps/photos/src/styles/photoswipe.css
index f1871c71c3..d13a041d0f 100644
--- a/web/apps/photos/src/styles/photoswipe.css
+++ b/web/apps/photos/src/styles/photoswipe.css
@@ -590,3 +590,16 @@ body:has(
right: -12px;
}
}
+
+/* Heart (like) button icons - uses pswp__hidden class toggled by showIf() */
+#pswp__icn-heart-fill {
+ display: none;
+}
+
+#pswp__icn-heart-fill:not(.pswp__hidden) {
+ display: inline;
+}
+
+#pswp__icn-heart.pswp__hidden {
+ display: none;
+}
diff --git a/web/packages/gallery/components/viewer/AddNameModal.tsx b/web/packages/gallery/components/viewer/AddNameModal.tsx
index 0377614baf..78b81afbaa 100644
--- a/web/packages/gallery/components/viewer/AddNameModal.tsx
+++ b/web/packages/gallery/components/viewer/AddNameModal.tsx
@@ -202,7 +202,11 @@ export const AddNameModal: React.FC<AddNameModalProps> = ({
<ContentContainer>
<IllustrationWrapper>
- {isComment ? <CommentIllustration /> : <LikeIllustration />}
+ {isComment ? (
+ <CommentIllustration />
+ ) : (
+ <LikeIllustration />
+ )}
</IllustrationWrapper>
<TitleSection>
@@ -229,7 +233,9 @@ export const AddNameModal: React.FC<AddNameModalProps> = ({
onClick={handleSubmit}
hasName={!!name.trim()}
>
- {isComment ? "Set name and comment" : "Set name and like"}
+ {isComment
+ ? "Set name and comment"
+ : "Set name and like"}
</SubmitButton>
</ContentContainer>
</DialogWrapper>
@@ -257,9 +263,7 @@ const StyledDialog = styled(Dialog)(({ theme }) => ({
border: "1px solid rgba(255, 255, 255, 0.18)",
}),
},
- "& .MuiBackdrop-root": {
- backgroundColor: "rgba(0, 0, 0, 0.5)",
- },
+ "& .MuiBackdrop-root": { backgroundColor: "rgba(0, 0, 0, 0.5)" },
}));
const DialogWrapper = styled(Box)(() => ({
@@ -274,9 +278,7 @@ const CloseButton = styled(IconButton)(({ theme }) => ({
backgroundColor: "#FAFAFA",
color: "#000",
padding: 10,
- "&:hover": {
- backgroundColor: "#F0F0F0",
- },
+ "&:hover": { backgroundColor: "#F0F0F0" },
...theme.applyStyles("dark", {
backgroundColor: "rgba(255, 255, 255, 0.12)",
color: "#fff",
@@ -313,9 +315,7 @@ const Title = styled(Typography)(({ theme }) => ({
lineHeight: "28px",
letterSpacing: "-0.48px",
color: "#000",
- ...theme.applyStyles("dark", {
- color: "#fff",
- }),
+ ...theme.applyStyles("dark", { color: "#fff" }),
}));
const Subtitle = styled(Typography)(({ theme }) => ({
@@ -324,9 +324,7 @@ const Subtitle = styled(Typography)(({ theme }) => ({
lineHeight: "20px",
color: "#666666",
maxWidth: 295,
- ...theme.applyStyles("dark", {
- color: "rgba(255, 255, 255, 0.7)",
- }),
+ ...theme.applyStyles("dark", { color: "rgba(255, 255, 255, 0.7)" }),
}));
const StyledTextField = styled(TextField)(({ theme }) => ({
@@ -334,12 +332,8 @@ const StyledTextField = styled(TextField)(({ theme }) => ({
height: 54,
backgroundColor: "#FAFAFA",
borderRadius: 12,
- "&::before": {
- borderBottom: "1px solid #E0E0E0",
- },
- "&::after": {
- borderBottom: "2px solid #08C225",
- },
+ "&::before": { borderBottom: "1px solid #E0E0E0" },
+ "&::after": { borderBottom: "2px solid #08C225" },
"&:hover:not(.Mui-disabled)::before": {
borderBottom: "1px solid #BDBDBD",
},
@@ -350,26 +344,19 @@ const StyledTextField = styled(TextField)(({ theme }) => ({
boxSizing: "border-box",
fontSize: 16,
color: "#000",
- "&::placeholder": {
- color: "#999",
- opacity: 1,
- },
+ "&::placeholder": { color: "#999", opacity: 1 },
},
...theme.applyStyles("dark", {
"& .MuiInput-root": {
backgroundColor: "rgba(255, 255, 255, 0.08)",
- "&::before": {
- borderBottom: "1px solid rgba(255, 255, 255, 0.3)",
- },
+ "&::before": { borderBottom: "1px solid rgba(255, 255, 255, 0.3)" },
"&:hover:not(.Mui-disabled)::before": {
borderBottom: "1px solid rgba(255, 255, 255, 0.5)",
},
},
"& .MuiInputBase-input": {
color: "#fff",
- "&::placeholder": {
- color: "rgba(255, 255, 255, 0.5)",
- },
+ "&::placeholder": { color: "rgba(255, 255, 255, 0.5)" },
},
}),
}));
@@ -394,9 +381,7 @@ const SubmitButton = styled(Button)<{ hasName: boolean }>(
boxShadow: "none",
},
...theme.applyStyles("dark", {
- backgroundColor: hasName
- ? "#08C225"
- : "rgba(255, 255, 255, 0.08)",
+ backgroundColor: hasName ? "#08C225" : "rgba(255, 255, 255, 0.08)",
color: hasName ? "#fff" : "rgba(255, 255, 255, 0.5)",
"&:hover": {
backgroundColor: hasName
diff --git a/web/packages/gallery/components/viewer/CommentsSidebar.tsx b/web/packages/gallery/components/viewer/CommentsSidebar.tsx
index afa973eb3a..c00c299cad 100644
--- a/web/packages/gallery/components/viewer/CommentsSidebar.tsx
+++ b/web/packages/gallery/components/viewer/CommentsSidebar.tsx
@@ -1167,9 +1167,10 @@ export const CommentsSidebar: React.FC<CommentsSidebarProps> = ({
fontWeight: 600,
fontSize: 14,
lineHeight: "20px",
- ...theme.applyStyles("dark", {
- color: "#fff",
- }),
+ ...theme.applyStyles(
+ "dark",
+ { color: "#fff" },
+ ),
})}
>
{collection.name}
@@ -1341,7 +1342,8 @@ export const CommentsSidebar: React.FC<CommentsSidebarProps> = ({
paddingLeft: "10px",
paddingRight: "24px",
...theme.applyStyles("dark", {
- borderLeft: "3px solid rgba(255, 255, 255, 0.3)",
+ borderLeft:
+ "3px solid rgba(255, 255, 255, 0.3)",
}),
})}
>
@@ -1540,10 +1542,7 @@ const CollectionBadge = styled(Box)(({ theme }) => ({
fontWeight: 600,
lineHeight: 1,
minWidth: 14,
- ...theme.applyStyles("dark", {
- backgroundColor: "#fff",
- color: "#000",
- }),
+ ...theme.applyStyles("dark", { backgroundColor: "#fff", color: "#000" }),
}));
const CollectionDropdownMenu = styled(Box)(({ theme }) => ({
@@ -1617,26 +1616,20 @@ const UserName = styled(Typography)(({ theme }) => ({
fontWeight: 600,
color: "#000",
fontSize: 14,
- ...theme.applyStyles("dark", {
- color: "#fff",
- }),
+ ...theme.applyStyles("dark", { color: "#fff" }),
}));
const Separator = styled(Typography)(({ theme }) => ({
color: "#666",
fontSize: 12,
marginLeft: -4,
- ...theme.applyStyles("dark", {
- color: "rgba(255, 255, 255, 0.7)",
- }),
+ ...theme.applyStyles("dark", { color: "rgba(255, 255, 255, 0.7)" }),
}));
const Timestamp = styled(Typography)(({ theme }) => ({
color: "#666",
fontSize: 12,
- ...theme.applyStyles("dark", {
- color: "rgba(255, 255, 255, 0.7)",
- }),
+ ...theme.applyStyles("dark", { color: "rgba(255, 255, 255, 0.7)" }),
}));
const OwnTimestamp = styled(Typography)(({ theme }) => ({
@@ -1645,9 +1638,7 @@ const OwnTimestamp = styled(Typography)(({ theme }) => ({
textAlign: "right",
marginBottom: 4,
paddingRight: 52,
- ...theme.applyStyles("dark", {
- color: "rgba(255, 255, 255, 0.7)",
- }),
+ ...theme.applyStyles("dark", { color: "rgba(255, 255, 255, 0.7)" }),
}));
// Comment Bubbles
@@ -1678,31 +1669,29 @@ const CommentBubble = styled(Box)<{ isOwn: boolean }>(({ isOwn, theme }) => ({
borderRadius: isOwn ? "20px 6px 20px 20px" : "6px 20px 20px 20px",
padding: "20px 40px 20px 20px",
width: "fit-content",
- ...(!isOwn &&
- theme.applyStyles("dark", {
- backgroundColor: "#363636",
- })),
+ ...(!isOwn && theme.applyStyles("dark", { backgroundColor: "#363636" })),
}));
-const CommentText = styled(Typography)<{ isOwn: boolean }>(({ isOwn, theme }) => ({
- color: isOwn ? "#fff" : "#000",
- fontSize: 14,
- whiteSpace: "pre-wrap",
- ...(!isOwn &&
- theme.applyStyles("dark", {
- color: "#fff",
- })),
-}));
+const CommentText = styled(Typography)<{ isOwn: boolean }>(
+ ({ isOwn, theme }) => ({
+ color: isOwn ? "#fff" : "#000",
+ fontSize: 14,
+ whiteSpace: "pre-wrap",
+ ...(!isOwn && theme.applyStyles("dark", { color: "#fff" })),
+ }),
+);
-const QuotedReplyContainer = styled(Box)<{ isOwn: boolean }>(({ isOwn, theme }) => ({
- borderLeft: `3px solid ${isOwn ? "rgba(255,255,255,0.5)" : "#ccc"}`,
- paddingLeft: 10,
- marginBottom: 16,
- ...(!isOwn &&
- theme.applyStyles("dark", {
- borderLeft: "3px solid rgba(255, 255, 255, 0.3)",
- })),
-}));
+const QuotedReplyContainer = styled(Box)<{ isOwn: boolean }>(
+ ({ isOwn, theme }) => ({
+ borderLeft: `3px solid ${isOwn ? "rgba(255,255,255,0.5)" : "#ccc"}`,
+ paddingLeft: 10,
+ marginBottom: 16,
+ ...(!isOwn &&
+ theme.applyStyles("dark", {
+ borderLeft: "3px solid rgba(255, 255, 255, 0.3)",
+ })),
+ }),
+);
// Actions
const ActionsContainer = styled(Box)(({ theme }) => ({
diff --git a/web/packages/gallery/components/viewer/FeedSidebar.tsx b/web/packages/gallery/components/viewer/FeedSidebar.tsx
index fbd21f6690..f29ea92980 100644
--- a/web/packages/gallery/components/viewer/FeedSidebar.tsx
+++ b/web/packages/gallery/components/viewer/FeedSidebar.tsx
@@ -260,7 +260,7 @@ type ThumbnailCache = Map<number, string>;
const CURRENT_USER_ID = 2;
// Mock user map for looking up user names by userID
-const mockUsers: Map<number, string> = new Map([
+const mockUsers = new Map<number, string>([
[CURRENT_USER_ID, "Anand"],
[4, "Vishnu"],
@@ -825,7 +825,11 @@ const getActionText = (item: FeedItem): string => {
const getUsersDisplayText = (users: FeedUser[]): string => {
if (users.length === 0) return "";
const firstName = truncateEmail(
- getUserDisplayName(users[0]!.userID, users[0]!.userName, users[0]!.anonUserID),
+ getUserDisplayName(
+ users[0]!.userID,
+ users[0]!.userName,
+ users[0]!.anonUserID,
+ ),
);
if (users.length === 1) {
return firstName;
@@ -1114,9 +1118,7 @@ const FeedItemContainer = styled(Box)(({ theme }) => ({
"repeating-linear-gradient(to bottom, rgba(255, 255, 255, 0.18) 0px, rgba(255, 255, 255, 0.18) 8px, transparent 8px, transparent 16px)",
}),
},
- "&:last-child": {
- marginBottom: 0,
- },
+ "&:last-child": { marginBottom: 0 },
}));
const IconContainer = styled(Box)(({ theme }) => ({
@@ -1130,9 +1132,7 @@ const IconContainer = styled(Box)(({ theme }) => ({
borderRadius: "50%",
position: "relative",
zIndex: 1,
- ...theme.applyStyles("dark", {
- backgroundColor: "#2a2a2a",
- }),
+ ...theme.applyStyles("dark", { backgroundColor: "#2a2a2a" }),
}));
const FeedItemContent = styled(Box)(() => ({
@@ -1158,9 +1158,7 @@ const StyledAvatar = styled(Avatar)(({ theme }) => ({
color: "#666",
border: "2px solid #FAFAFA",
marginLeft: -8,
- "&:first-of-type": {
- marginLeft: 0,
- },
+ "&:first-of-type": { marginLeft: 0 },
...theme.applyStyles("dark", {
backgroundColor: "#3a3a3a",
color: "#b0b0b0",
@@ -1175,9 +1173,7 @@ const UserNameText = styled(Typography)(({ theme }) => ({
whiteSpace: "nowrap",
overflow: "hidden",
textOverflow: "ellipsis",
- ...theme.applyStyles("dark", {
- color: "#fff",
- }),
+ ...theme.applyStyles("dark", { color: "#fff" }),
}));
const ActionText = styled(Typography)(({ theme }) => ({
@@ -1186,9 +1182,7 @@ const ActionText = styled(Typography)(({ theme }) => ({
whiteSpace: "nowrap",
overflow: "hidden",
textOverflow: "ellipsis",
- ...theme.applyStyles("dark", {
- color: "rgba(255, 255, 255, 0.7)",
- }),
+ ...theme.applyStyles("dark", { color: "rgba(255, 255, 255, 0.7)" }),
}));
const ThumbnailImage = styled("img")(() => ({
diff --git a/web/packages/gallery/components/viewer/FileViewer.tsx b/web/packages/gallery/components/viewer/FileViewer.tsx
index 8caa7f91f6..81b6df29b7 100644
--- a/web/packages/gallery/components/viewer/FileViewer.tsx
+++ b/web/packages/gallery/components/viewer/FileViewer.tsx
@@ -46,6 +46,12 @@ import {
ImageEditorOverlay,
type ImageEditorOverlayProps,
} from "ente-new/photos/components/ImageEditorOverlay";
+import { getCollectionByID } from "ente-new/photos/services/collection";
+import {
+ addReaction,
+ deleteReaction,
+ getFileReactions,
+} from "ente-new/photos/services/reaction";
import { t } from "i18next";
import React, {
useCallback,
@@ -54,6 +60,7 @@ import React, {
useRef,
useState,
} from "react";
+import { AddNameModal } from "./AddNameModal";
import { CommentsSidebar } from "./CommentsSidebar";
import {
fileInfoExifForFile,
@@ -61,9 +68,8 @@ import {
type ItemData,
} from "./data-source";
import { LikeAlbumSelectorModal } from "./LikeAlbumSelectorModal";
+import { UnlikeAlbumSelectorModal } from "./UnlikeAlbumSelectorModal";
import { LikesSidebar } from "./LikesSidebar";
-import { AddNameModal } from "./AddNameModal";
-import { PublicLikeModal } from "./PublicLikeModal";
import {
FileViewerPhotoSwipe,
moreButtonID,
@@ -71,6 +77,7 @@ import {
resetMoreMenuButtonOnMenuClose,
type FileViewerPhotoSwipeDelegate,
} from "./photoswipe";
+import { PublicLikeModal } from "./PublicLikeModal";
/**
* Derived data for a file that is needed to display the file viewer controls
@@ -402,6 +409,19 @@ export const FileViewer: React.FC<FileViewerProps> = ({
const [isFullscreen, setIsFullscreen] = useState(false);
+ // Map of file ID to array of reactions (collectionId + reactionId) for the current user.
+ // For gallery view, we track reactions across all collections.
+ // For collection view, we only track the reaction in that collection.
+ interface FileReaction {
+ collectionId: number;
+ reactionId: string;
+ }
+ const [fileReactions, setFileReactions] = useState<
+ Map<number, FileReaction[]>
+ >(new Map());
+
+ const [openUnlikeAlbumSelector, setOpenUnlikeAlbumSelector] = useState(false);
+
// If `true`, then we need to trigger a pull from remote when we close.
const [, setNeedsRemotePull] = useState(false);
@@ -419,6 +439,7 @@ export const FileViewer: React.FC<FileViewerProps> = ({
setOpenComments(false);
setOpenLikes(false);
setOpenLikeAlbumSelector(false);
+ setOpenUnlikeAlbumSelector(false);
setOpenPublicLikeModal(false);
// No need to `resetMoreMenuButtonOnMenuClose` since we're closing
// anyway and it'll be removed from the DOM.
@@ -451,31 +472,119 @@ export const FileViewer: React.FC<FileViewerProps> = ({
const handleLikesClose = useCallback(() => setOpenLikes(false), []);
+ // Refs to access current state without causing re-renders
+ // when used in callbacks that are dependencies of the PhotoSwipe effect.
+ const activeAnnotatedFileRef = useRef(activeAnnotatedFile);
+ activeAnnotatedFileRef.current = activeAnnotatedFile;
+
+ const fileReactionsRef = useRef(fileReactions);
+ fileReactionsRef.current = fileReactions;
+
// Called when the like button (heart) is clicked.
// - If public album (has ?t=): show PublicLikeModal
- // - If collection context (has ?collection=): perform like action directly
- // - If no collection context: show album selector modal
+ // - If gallery view: show album selector (like) OR unlike selector/direct delete
+ // - If collection view: toggle like in that collection
const handleLikeClick = useCallback(() => {
const searchParams =
typeof window !== "undefined"
? new URLSearchParams(window.location.search)
: new URLSearchParams();
const isPublicAlbum = searchParams.has("t");
- const hasCollectionContext = searchParams.has("collection");
if (isPublicAlbum) {
// Public album - show public like modal
setOpenPublicLikeModal(true);
- } else if (hasCollectionContext) {
- // Collection context exists - perform like action directly
- // TODO: Implement actual like action when API is available
- const collectionId = searchParams.get("collection");
- console.log(`Like action: collection=${collectionId}`);
+ return;
+ }
+
+ const file = activeAnnotatedFileRef.current?.file;
+ if (!file) return;
+
+ const fileId = file.id;
+ const reactions = fileReactionsRef.current.get(fileId) ?? [];
+ const isGalleryView = !activeCollectionID || activeCollectionID === 0;
+
+ if (isGalleryView) {
+ // Gallery view
+ if (reactions.length === 0) {
+ // Not liked in any collection - show album selector to add
+ setOpenLikeAlbumSelector(true);
+ } else if (reactions.length === 1) {
+ // Liked in exactly one collection - delete directly
+ const reaction = reactions[0]!;
+ void (async () => {
+ try {
+ await deleteReaction(reaction.reactionId);
+ log.info(`Deleted reaction: ${reaction.reactionId}`);
+ setFileReactions((prev) => {
+ const next = new Map(prev);
+ next.delete(fileId);
+ return next;
+ });
+ } catch (e) {
+ log.error("Failed to delete reaction", e);
+ }
+ })();
+ } else {
+ // Liked in multiple collections - show unlike album selector
+ setOpenUnlikeAlbumSelector(true);
+ }
} else {
- // No collection context - show album selector modal
- setOpenLikeAlbumSelector(true);
+ // Collection view - toggle like in this specific collection
+ const existingReaction = reactions.find(
+ (r) => r.collectionId === activeCollectionID,
+ );
+
+ if (existingReaction) {
+ // Already liked in this collection - delete
+ void (async () => {
+ try {
+ await deleteReaction(existingReaction.reactionId);
+ log.info(`Deleted reaction: ${existingReaction.reactionId}`);
+ setFileReactions((prev) => {
+ const next = new Map(prev);
+ const updated = (prev.get(fileId) ?? []).filter(
+ (r) => r.reactionId !== existingReaction.reactionId,
+ );
+ if (updated.length > 0) {
+ next.set(fileId, updated);
+ } else {
+ next.delete(fileId);
+ }
+ return next;
+ });
+ } catch (e) {
+ log.error("Failed to delete reaction", e);
+ }
+ })();
+ } else {
+ // Not liked in this collection - add
+ void (async () => {
+ try {
+ const collection = await getCollectionByID(activeCollectionID);
+ const reactionId = await addReaction(
+ activeCollectionID,
+ fileId,
+ "green_heart",
+ collection.key,
+ );
+ log.info(`Added reaction: ${reactionId}`);
+ setFileReactions((prev) => {
+ const next = new Map(prev);
+ const existing = prev.get(fileId) ?? [];
+ next.set(fileId, [
+ ...existing,
+ { collectionId: activeCollectionID, reactionId },
+ ]);
+ return next;
+ });
+ } catch (e) {
+ log.error("Failed to add reaction", e);
+ }
+ })();
+ }
}
- }, []);
+ }, [activeCollectionID]);
const handleLikeAlbumSelectorClose = useCallback(
() => setOpenLikeAlbumSelector(false),
@@ -494,6 +603,103 @@ export const FileViewer: React.FC<FileViewerProps> = ({
setOpenLikeAlbumSelector(false);
}, []);
+ const handleUnlikeAlbumSelectorClose = useCallback(
+ () => setOpenUnlikeAlbumSelector(false),
+ [],
+ );
+
+ const handleToggleAlbumLike = useCallback(
+ (albumId: number, isCurrentlyLiked: boolean) => {
+ const file = activeAnnotatedFileRef.current?.file;
+ if (!file) return;
+
+ const fileId = file.id;
+
+ if (isCurrentlyLiked) {
+ // Unlike - delete the reaction
+ const reactions = fileReactionsRef.current.get(fileId) ?? [];
+ const reactionToDelete = reactions.find(
+ (r) => r.collectionId === albumId,
+ );
+
+ if (reactionToDelete) {
+ void (async () => {
+ try {
+ await deleteReaction(reactionToDelete.reactionId);
+ log.info(`Deleted reaction: ${reactionToDelete.reactionId}`);
+ setFileReactions((prev) => {
+ const next = new Map(prev);
+ const updated = (prev.get(fileId) ?? []).filter(
+ (r) => r.reactionId !== reactionToDelete.reactionId,
+ );
+ if (updated.length > 0) {
+ next.set(fileId, updated);
+ } else {
+ next.delete(fileId);
+ }
+ return next;
+ });
+ } catch (e) {
+ log.error("Failed to delete reaction", e);
+ }
+ })();
+ }
+ } else {
+ // Like - add a reaction
+ void (async () => {
+ try {
+ const collection = await getCollectionByID(albumId);
+ const reactionId = await addReaction(
+ albumId,
+ fileId,
+ "green_heart",
+ collection.key,
+ );
+ log.info(`Added reaction: ${reactionId}`);
+ setFileReactions((prev) => {
+ const next = new Map(prev);
+ const existing = prev.get(fileId) ?? [];
+ next.set(fileId, [
+ ...existing,
+ { collectionId: albumId, reactionId },
+ ]);
+ return next;
+ });
+ } catch (e) {
+ log.error("Failed to add reaction", e);
+ }
+ })();
+ }
+ // Don't close - user might want to toggle more albums
+ },
+ [],
+ );
+
+ const handleUnlikeAll = useCallback(() => {
+ const file = activeAnnotatedFileRef.current?.file;
+ if (!file) return;
+
+ const fileId = file.id;
+ const reactions = fileReactionsRef.current.get(fileId) ?? [];
+
+ void (async () => {
+ try {
+ for (const reaction of reactions) {
+ await deleteReaction(reaction.reactionId);
+ log.info(`Deleted reaction: ${reaction.reactionId}`);
+ }
+ setFileReactions((prev) => {
+ const next = new Map(prev);
+ next.delete(fileId);
+ return next;
+ });
+ } catch (e) {
+ log.error("Failed to delete reactions", e);
+ }
+ })();
+ setOpenUnlikeAlbumSelector(false);
+ }, []);
+
const handlePublicLikeModalClose = useCallback(
() => setOpenPublicLikeModal(false),
[],
@@ -723,6 +929,25 @@ export const FileViewer: React.FC<FileViewerProps> = ({
const haveUser = !!user;
+ // Compute all albums and liked album IDs for the unlike selector modal
+ const { allAlbumsForFile, likedAlbumIDs } = useMemo(() => {
+ const file = activeAnnotatedFile?.file;
+ if (!file) return { allAlbumsForFile: [], likedAlbumIDs: new Set<number>() };
+
+ // Get all collections the file belongs to
+ const collectionIDs = fileNormalCollectionIDs?.get(file.id) ?? [];
+ const allAlbumsForFile = collectionIDs.map((id) => ({
+ id,
+ name: collectionNameByID?.get(id) ?? `Album ${id}`,
+ }));
+
+ // Get the set of liked album IDs
+ const reactions = fileReactions.get(file.id) ?? [];
+ const likedAlbumIDs = new Set(reactions.map((r) => r.collectionId));
+
+ return { allAlbumsForFile, likedAlbumIDs };
+ }, [activeAnnotatedFile, fileReactions, collectionNameByID, fileNormalCollectionIDs]);
+
const getFiles = useCallback(() => files, [files]);
const isFavorite = useCallback(
@@ -754,6 +979,14 @@ export const FileViewer: React.FC<FileViewerProps> = ({
[onToggleFavorite, onGenericError, handleNeedsRemotePull],
);
+ const isLiked = useCallback(
+ ({ file }: FileViewerAnnotatedFile) => {
+ const reactions = fileReactions.get(file.id);
+ return reactions !== undefined && reactions.length > 0;
+ },
+ [fileReactions],
+ );
+
const updateFullscreenStatus = useCallback(() => {
setIsFullscreen(!!document.fullscreenElement);
}, []);
@@ -781,6 +1014,7 @@ export const FileViewer: React.FC<FileViewerProps> = ({
openComments ||
openLikes ||
openLikeAlbumSelector ||
+ openUnlikeAlbumSelector ||
openPublicLikeModal ||
!!moreMenuAnchorEl ||
openImageEditor ||
@@ -814,6 +1048,7 @@ export const FileViewer: React.FC<FileViewerProps> = ({
openComments,
openLikes,
openLikeAlbumSelector,
+ openUnlikeAlbumSelector,
openPublicLikeModal,
moreMenuAnchorEl,
openImageEditor,
@@ -927,6 +1162,7 @@ export const FileViewer: React.FC<FileViewerProps> = ({
isFavorite,
isFavoritePending,
toggleFavorite,
+ isLiked,
shouldIgnoreKeyboardEvent,
performKeyAction,
};
@@ -939,6 +1175,7 @@ export const FileViewer: React.FC<FileViewerProps> = ({
delegate.isFavorite = isFavorite;
delegate.isFavoritePending = isFavoritePending;
delegate.toggleFavorite = toggleFavorite;
+ delegate.isLiked = isLiked;
delegate.shouldIgnoreKeyboardEvent = shouldIgnoreKeyboardEvent;
delegate.performKeyAction = performKeyAction;
}, [
@@ -946,6 +1183,7 @@ export const FileViewer: React.FC<FileViewerProps> = ({
isFavorite,
isFavoritePending,
toggleFavorite,
+ isLiked,
shouldIgnoreKeyboardEvent,
performKeyAction,
]);
@@ -979,6 +1217,97 @@ export const FileViewer: React.FC<FileViewerProps> = ({
}
}, [favoriteFileIDs, pendingFavoriteUpdates, files, open]);
+ // Refresh like button when fileReactions changes.
+ useEffect(() => {
+ if (open && files.length) {
+ psRef.current?.refreshCurrentSlideLikeButtonIfNeeded();
+ }
+ }, [fileReactions, files, open]);
+
+ // Fetch reactions for the current file when it changes.
+ // Track by file ID to avoid re-fetching when activeAnnotatedFile object changes identity.
+ const activeFileID = activeAnnotatedFile?.file.id;
+ useEffect(() => {
+ if (!open || !activeFileID) return;
+
+ const isGalleryView = !activeCollectionID || activeCollectionID === 0;
+
+ void (async () => {
+ try {
+ if (isGalleryView) {
+ // Gallery view: check ALL collections the file belongs to
+ const collectionIDs = fileNormalCollectionIDs?.get(activeFileID) ?? [];
+ const foundReactions: FileReaction[] = [];
+
+ for (const collectionId of collectionIDs) {
+ try {
+ const collection = await getCollectionByID(collectionId);
+ const reactions = await getFileReactions(
+ collectionId,
+ activeFileID,
+ collection.key,
+ );
+ const userReaction = reactions.find(
+ (r) =>
+ r.reactionType === "green_heart" &&
+ r.userID === user?.id,
+ );
+ if (userReaction) {
+ foundReactions.push({
+ collectionId,
+ reactionId: userReaction.id,
+ });
+ }
+ } catch {
+ // Skip collections that fail to fetch
+ }
+ }
+
+ setFileReactions((prev) => {
+ const next = new Map(prev);
+ if (foundReactions.length > 0) {
+ next.set(activeFileID, foundReactions);
+ } else {
+ next.delete(activeFileID);
+ }
+ return next;
+ });
+ } else {
+ // Collection view: check only the active collection
+ const collection = await getCollectionByID(activeCollectionID);
+ const reactions = await getFileReactions(
+ activeCollectionID,
+ activeFileID,
+ collection.key,
+ );
+ const userReaction = reactions.find(
+ (r) =>
+ r.reactionType === "green_heart" &&
+ r.userID === user?.id,
+ );
+ setFileReactions((prev) => {
+ const next = new Map(prev);
+ if (userReaction) {
+ next.set(activeFileID, [
+ { collectionId: activeCollectionID, reactionId: userReaction.id },
+ ]);
+ } else {
+ next.delete(activeFileID);
+ }
+ return next;
+ });
+ }
+ } catch (e) {
+ log.error("Failed to fetch reactions", e);
+ setFileReactions((prev) => {
+ const next = new Map(prev);
+ next.delete(activeFileID);
+ return next;
+ });
+ }
+ })();
+ }, [open, activeFileID, activeCollectionID, fileNormalCollectionIDs, user?.id]);
+
useEffect(() => {
if (open) {
// We're open. Create psRef. This will show the file viewer dialog.
@@ -1087,6 +1416,14 @@ export const FileViewer: React.FC<FileViewerProps> = ({
onSelectAlbum={handleSelectAlbumForLike}
onLikeAll={handleLikeAll}
/>
+ <UnlikeAlbumSelectorModal
+ open={openUnlikeAlbumSelector}
+ onClose={handleUnlikeAlbumSelectorClose}
+ albums={allAlbumsForFile}
+ likedAlbumIDs={likedAlbumIDs}
+ onToggleAlbum={handleToggleAlbumLike}
+ onUnlikeAll={handleUnlikeAll}
+ />
<PublicLikeModal
open={openPublicLikeModal}
onClose={handlePublicLikeModalClose}
diff --git a/web/packages/gallery/components/viewer/LikeAlbumSelectorModal.tsx b/web/packages/gallery/components/viewer/LikeAlbumSelectorModal.tsx
index 85577073d3..9d6cc43cf3 100644
--- a/web/packages/gallery/components/viewer/LikeAlbumSelectorModal.tsx
+++ b/web/packages/gallery/components/viewer/LikeAlbumSelectorModal.tsx
@@ -1,11 +1,5 @@
import CloseIcon from "@mui/icons-material/Close";
-import {
- Box,
- Dialog,
- IconButton,
- styled,
- Typography,
-} from "@mui/material";
+import { Box, Dialog, IconButton, styled, Typography } from "@mui/material";
import { type ModalVisibilityProps } from "ente-base/components/utils/modal";
import React from "react";
@@ -214,9 +208,7 @@ const StyledDialog = styled(Dialog)(({ theme }) => ({
border: "1px solid rgba(255, 255, 255, 0.18)",
}),
},
- "& .MuiBackdrop-root": {
- backgroundColor: "rgba(0, 0, 0, 0.5)",
- },
+ "& .MuiBackdrop-root": { backgroundColor: "rgba(0, 0, 0, 0.5)" },
}));
const DialogWrapper = styled(Box)(() => ({
@@ -231,9 +223,7 @@ const CloseButton = styled(IconButton)(({ theme }) => ({
backgroundColor: "#FAFAFA",
color: "#000",
padding: 10,
- "&:hover": {
- backgroundColor: "#F0F0F0",
- },
+ "&:hover": { backgroundColor: "#F0F0F0" },
...theme.applyStyles("dark", {
backgroundColor: "rgba(255, 255, 255, 0.12)",
color: "#fff",
@@ -270,9 +260,7 @@ const Title = styled(Typography)(({ theme }) => ({
lineHeight: "22px",
letterSpacing: "-0.48px",
color: "#000",
- ...theme.applyStyles("dark", {
- color: "#fff",
- }),
+ ...theme.applyStyles("dark", { color: "#fff" }),
}));
const Subtitle = styled(Typography)(({ theme }) => ({
@@ -281,9 +269,7 @@ const Subtitle = styled(Typography)(({ theme }) => ({
lineHeight: "17px",
color: "#666666",
maxWidth: 295,
- ...theme.applyStyles("dark", {
- color: "rgba(255, 255, 255, 0.7)",
- }),
+ ...theme.applyStyles("dark", { color: "rgba(255, 255, 255, 0.7)" }),
}));
const AlbumsSection = styled(Box)(({ theme }) => ({
@@ -313,9 +299,7 @@ const AlbumsCount = styled(Typography)(({ theme }) => ({
fontSize: 14,
lineHeight: "17px",
color: "#000",
- ...theme.applyStyles("dark", {
- color: "#fff",
- }),
+ ...theme.applyStyles("dark", { color: "#fff" }),
}));
const LikeAllButton = styled(Box)(({ theme }) => ({
@@ -326,9 +310,7 @@ const LikeAllButton = styled(Box)(({ theme }) => ({
backgroundColor: "#fff",
borderRadius: 14,
cursor: "pointer",
- "&:hover": {
- backgroundColor: "#EBEBEB",
- },
+ "&:hover": { backgroundColor: "#EBEBEB" },
...theme.applyStyles("dark", {
backgroundColor: "#1b1b1b",
"&:hover": { backgroundColor: "#252525" },
@@ -342,12 +324,8 @@ const AlbumsList = styled(Box)(({ theme }) => ({
padding: "0 12px 12px 12px",
overflowY: "auto",
maxHeight: 241,
- "&::-webkit-scrollbar": {
- width: 6,
- },
- "&::-webkit-scrollbar-track": {
- background: "transparent",
- },
+ "&::-webkit-scrollbar": { width: 6 },
+ "&::-webkit-scrollbar-track": { background: "transparent" },
"&::-webkit-scrollbar-thumb": {
background: "rgba(0, 0, 0, 0.2)",
borderRadius: 3,
@@ -367,9 +345,7 @@ const AlbumItem = styled(Box)(({ theme }) => ({
padding: "10px 10px 10px 16px",
backgroundColor: "#fff",
borderRadius: 16,
- ...theme.applyStyles("dark", {
- backgroundColor: "#212121",
- }),
+ ...theme.applyStyles("dark", { backgroundColor: "#212121" }),
}));
const AlbumName = styled(Typography)(({ theme }) => ({
@@ -378,9 +354,7 @@ const AlbumName = styled(Typography)(({ theme }) => ({
lineHeight: "17px",
color: "#000",
flex: 1,
- ...theme.applyStyles("dark", {
- color: "#fff",
- }),
+ ...theme.applyStyles("dark", { color: "#fff" }),
}));
const HeartButton = styled(Box)(() => ({
@@ -392,7 +366,5 @@ const HeartButton = styled(Box)(() => ({
backgroundColor: "rgba(8, 194, 37, 0.06)",
borderRadius: 9.6,
cursor: "pointer",
- "&:hover": {
- backgroundColor: "rgba(8, 194, 37, 0.12)",
- },
+ "&:hover": { backgroundColor: "rgba(8, 194, 37, 0.12)" },
}));
diff --git a/web/packages/gallery/components/viewer/LikesSidebar.tsx b/web/packages/gallery/components/viewer/LikesSidebar.tsx
index c7a5627197..ee28869d93 100644
--- a/web/packages/gallery/components/viewer/LikesSidebar.tsx
+++ b/web/packages/gallery/components/viewer/LikesSidebar.tsx
@@ -230,9 +230,10 @@ export const LikesSidebar: React.FC<LikesSidebarProps> = ({
fontWeight: 600,
fontSize: 14,
lineHeight: "20px",
- ...theme.applyStyles("dark", {
- color: "#fff",
- }),
+ ...theme.applyStyles(
+ "dark",
+ { color: "#fff" },
+ ),
})}
>
{collection.name}
@@ -379,10 +380,7 @@ const CollectionBadge = styled(Box)(({ theme }) => ({
fontWeight: 600,
lineHeight: 1,
minWidth: 14,
- ...theme.applyStyles("dark", {
- backgroundColor: "#fff",
- color: "#000",
- }),
+ ...theme.applyStyles("dark", { backgroundColor: "#fff", color: "#000" }),
}));
const CollectionDropdownMenu = styled(Box)(({ theme }) => ({
@@ -453,9 +451,7 @@ const LikerName = styled(Typography)(({ theme }) => ({
fontWeight: 500,
color: "#000",
fontSize: 14,
- ...theme.applyStyles("dark", {
- color: "#fff",
- }),
+ ...theme.applyStyles("dark", { color: "#fff" }),
}));
// Context Menu Overlay
diff --git a/web/packages/gallery/components/viewer/PublicCommentModal.tsx b/web/packages/gallery/components/viewer/PublicCommentModal.tsx
index e9d82da99a..aca1c53778 100644
--- a/web/packages/gallery/components/viewer/PublicCommentModal.tsx
+++ b/web/packages/gallery/components/viewer/PublicCommentModal.tsx
@@ -1,5 +1,12 @@
import CloseIcon from "@mui/icons-material/Close";
-import { Box, Button, Dialog, IconButton, styled, Typography } from "@mui/material";
+import {
+ Box,
+ Button,
+ Dialog,
+ IconButton,
+ styled,
+ Typography,
+} from "@mui/material";
import { type ModalVisibilityProps } from "ente-base/components/utils/modal";
import React from "react";
@@ -170,9 +177,7 @@ const StyledDialog = styled(Dialog)(({ theme }) => ({
border: "1px solid rgba(255, 255, 255, 0.18)",
}),
},
- "& .MuiBackdrop-root": {
- backgroundColor: "rgba(0, 0, 0, 0.5)",
- },
+ "& .MuiBackdrop-root": { backgroundColor: "rgba(0, 0, 0, 0.5)" },
}));
const DialogWrapper = styled(Box)(() => ({
@@ -187,9 +192,7 @@ const CloseButton = styled(IconButton)(({ theme }) => ({
backgroundColor: "#FAFAFA",
color: "#000",
padding: 10,
- "&:hover": {
- backgroundColor: "#F0F0F0",
- },
+ "&:hover": { backgroundColor: "#F0F0F0" },
...theme.applyStyles("dark", {
backgroundColor: "rgba(255, 255, 255, 0.12)",
color: "#fff",
@@ -226,9 +229,7 @@ const Title = styled(Typography)(({ theme }) => ({
lineHeight: "28px",
letterSpacing: "-0.48px",
color: "#000",
- ...theme.applyStyles("dark", {
- color: "#fff",
- }),
+ ...theme.applyStyles("dark", { color: "#fff" }),
}));
const Subtitle = styled(Typography)(({ theme }) => ({
@@ -237,9 +238,7 @@ const Subtitle = styled(Typography)(({ theme }) => ({
lineHeight: "20px",
color: "#666666",
maxWidth: 295,
- ...theme.applyStyles("dark", {
- color: "rgba(255, 255, 255, 0.7)",
- }),
+ ...theme.applyStyles("dark", { color: "rgba(255, 255, 255, 0.7)" }),
}));
const ButtonsSection = styled(Box)(() => ({
@@ -263,16 +262,11 @@ const AnonymousButton = styled(Button)(({ theme }) => ({
fontWeight: 500,
textTransform: "none",
color: "#000",
- "&:hover": {
- backgroundColor: "rgba(0, 0, 0, 0.08)",
- border: "none",
- },
+ "&:hover": { backgroundColor: "rgba(0, 0, 0, 0.08)", border: "none" },
...theme.applyStyles("dark", {
backgroundColor: "rgba(255, 255, 255, 0.08)",
color: "#fff",
- "&:hover": {
- backgroundColor: "rgba(255, 255, 255, 0.12)",
- },
+ "&:hover": { backgroundColor: "rgba(255, 255, 255, 0.12)" },
}),
}));
@@ -289,7 +283,5 @@ const SignInButton = styled(Button)(() => ({
fontWeight: 500,
textTransform: "none",
color: "#fff",
- "&:hover": {
- backgroundColor: "#07A820",
- },
+ "&:hover": { backgroundColor: "#07A820" },
}));
diff --git a/web/packages/gallery/components/viewer/PublicLikeModal.tsx b/web/packages/gallery/components/viewer/PublicLikeModal.tsx
index 48bafb4e40..0afbb2ee00 100644
--- a/web/packages/gallery/components/viewer/PublicLikeModal.tsx
+++ b/web/packages/gallery/components/viewer/PublicLikeModal.tsx
@@ -1,5 +1,12 @@
import CloseIcon from "@mui/icons-material/Close";
-import { Box, Button, Dialog, IconButton, styled, Typography } from "@mui/material";
+import {
+ Box,
+ Button,
+ Dialog,
+ IconButton,
+ styled,
+ Typography,
+} from "@mui/material";
import { type ModalVisibilityProps } from "ente-base/components/utils/modal";
import React from "react";
@@ -158,9 +165,7 @@ const StyledDialog = styled(Dialog)(({ theme }) => ({
border: "1px solid rgba(255, 255, 255, 0.18)",
}),
},
- "& .MuiBackdrop-root": {
- backgroundColor: "rgba(0, 0, 0, 0.5)",
- },
+ "& .MuiBackdrop-root": { backgroundColor: "rgba(0, 0, 0, 0.5)" },
}));
const DialogWrapper = styled(Box)(() => ({
@@ -175,9 +180,7 @@ const CloseButton = styled(IconButton)(({ theme }) => ({
backgroundColor: "#FAFAFA",
color: "#000",
padding: 10,
- "&:hover": {
- backgroundColor: "#F0F0F0",
- },
+ "&:hover": { backgroundColor: "#F0F0F0" },
...theme.applyStyles("dark", {
backgroundColor: "rgba(255, 255, 255, 0.12)",
color: "#fff",
@@ -214,9 +217,7 @@ const Title = styled(Typography)(({ theme }) => ({
lineHeight: "28px",
letterSpacing: "-0.48px",
color: "#000",
- ...theme.applyStyles("dark", {
- color: "#fff",
- }),
+ ...theme.applyStyles("dark", { color: "#fff" }),
}));
const Subtitle = styled(Typography)(({ theme }) => ({
@@ -225,9 +226,7 @@ const Subtitle = styled(Typography)(({ theme }) => ({
lineHeight: "20px",
color: "#666666",
maxWidth: 295,
- ...theme.applyStyles("dark", {
- color: "rgba(255, 255, 255, 0.7)",
- }),
+ ...theme.applyStyles("dark", { color: "rgba(255, 255, 255, 0.7)" }),
}));
const ButtonsSection = styled(Box)(() => ({
@@ -251,16 +250,11 @@ const AnonymousButton = styled(Button)(({ theme }) => ({
fontWeight: 500,
textTransform: "none",
color: "#000",
- "&:hover": {
- backgroundColor: "rgba(0, 0, 0, 0.08)",
- border: "none",
- },
+ "&:hover": { backgroundColor: "rgba(0, 0, 0, 0.08)", border: "none" },
...theme.applyStyles("dark", {
backgroundColor: "rgba(255, 255, 255, 0.08)",
color: "#fff",
- "&:hover": {
- backgroundColor: "rgba(255, 255, 255, 0.12)",
- },
+ "&:hover": { backgroundColor: "rgba(255, 255, 255, 0.12)" },
}),
}));
@@ -277,7 +271,5 @@ const SignInButton = styled(Button)(() => ({
fontWeight: 500,
textTransform: "none",
color: "#fff",
- "&:hover": {
- backgroundColor: "#07A820",
- },
+ "&:hover": { backgroundColor: "#07A820" },
}));
diff --git a/web/packages/gallery/components/viewer/UnlikeAlbumSelectorModal.tsx b/web/packages/gallery/components/viewer/UnlikeAlbumSelectorModal.tsx
new file mode 100644
index 0000000000..9de505fbba
--- /dev/null
+++ b/web/packages/gallery/components/viewer/UnlikeAlbumSelectorModal.tsx
@@ -0,0 +1,367 @@
+import CloseIcon from "@mui/icons-material/Close";
+import { Box, Dialog, IconButton, styled, Typography } from "@mui/material";
+import { type ModalVisibilityProps } from "ente-base/components/utils/modal";
+import React from "react";
+
+// =============================================================================
+// Icons
+// =============================================================================
+
+const HeartFilledIcon: React.FC<{ size?: number; color?: string }> = ({
+ size = 18,
+ color = "#08C225",
+}) => (
+ <svg
+ width={size}
+ height={(size * 15) / 18}
+ viewBox="0 0 18 15"
+ fill="none"
+ xmlns="http://www.w3.org/2000/svg"
+ style={{ display: "block" }}
+ >
+ <path
+ d="M7.40825 13.8538C5.15122 12.1661 0.679688 8.30753 0.679688 4.83524C0.679688 2.54019 2.3639 0.679688 4.67969 0.679688C5.87969 0.679688 7.07969 1.07969 8.67969 2.67969C10.2797 1.07969 11.4797 0.679688 12.6797 0.679688C14.9954 0.679688 16.6797 2.54019 16.6797 4.83524C16.6797 8.30753 12.2082 12.1661 9.95113 13.8538C9.19161 14.4218 8.16777 14.4218 7.40825 13.8538Z"
+ fill={color}
+ stroke={color}
+ strokeWidth="1.36"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ />
+ </svg>
+);
+
+const HeartOutlineIcon: React.FC<{ size?: number; color?: string }> = ({
+ size = 18,
+ color = "#08C225",
+}) => (
+ <svg
+ width={size}
+ height={(size * 15) / 18}
+ viewBox="0 0 18 15"
+ fill="none"
+ xmlns="http://www.w3.org/2000/svg"
+ style={{ display: "block" }}
+ >
+ <path
+ d="M7.40825 13.8538C5.15122 12.1661 0.679688 8.30753 0.679688 4.83524C0.679688 2.54019 2.3639 0.679688 4.67969 0.679688C5.87969 0.679688 7.07969 1.07969 8.67969 2.67969C10.2797 1.07969 11.4797 0.679688 12.6797 0.679688C14.9954 0.679688 16.6797 2.54019 16.6797 4.83524C16.6797 8.30753 12.2082 12.1661 9.95113 13.8538C9.19161 14.4218 8.16777 14.4218 7.40825 13.8538Z"
+ stroke={color}
+ strokeWidth="1.36"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ />
+ </svg>
+);
+
+const UnlikePhotoIllustration: React.FC = () => (
+ <svg
+ width="126"
+ height="121"
+ viewBox="0 0 126 121"
+ fill="none"
+ xmlns="http://www.w3.org/2000/svg"
+ >
+ <path
+ d="M84.7129 23.0781C96.7222 23.0784 105.29 32.8476 105.29 44.499C105.29 53.3449 99.7258 62.2116 93.4453 69.4932C87.0622 76.8936 79.4391 83.2238 74.3574 87.0557C69.973 90.3616 64.031 90.3614 59.6465 87.0557C54.5648 83.2238 46.9408 76.8937 40.5576 69.4932C34.2771 62.2116 28.7129 53.3449 28.7129 44.499C28.713 32.8474 37.2813 23.0781 49.291 23.0781C54.9545 23.0782 60.4297 24.9062 67.001 30.9004C73.5726 24.9056 79.0491 23.0781 84.7129 23.0781Z"
+ fill="none"
+ stroke="#888"
+ strokeWidth="5.73358"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeDasharray="10 10"
+ />
+ </svg>
+);
+
+// =============================================================================
+// Types
+// =============================================================================
+
+interface Album {
+ id: number;
+ name: string;
+}
+
+export interface UnlikeAlbumSelectorModalProps extends ModalVisibilityProps {
+ /**
+ * List of all albums the file belongs to.
+ */
+ albums: Album[];
+ /**
+ * Set of album IDs where the photo is currently liked.
+ */
+ likedAlbumIDs: Set<number>;
+ /**
+ * Called when user clicks on an album to toggle like status.
+ * @param albumId The album ID
+ * @param isCurrentlyLiked Whether the album is currently liked
+ */
+ onToggleAlbum: (albumId: number, isCurrentlyLiked: boolean) => void;
+ /**
+ * Called when user clicks "Unlike all" to remove likes from all albums.
+ */
+ onUnlikeAll: () => void;
+}
+
+/**
+ * Modal dialog for managing likes across albums.
+ * Shown when the like button is clicked and the photo is liked
+ * in multiple albums (from gallery view).
+ */
+export const UnlikeAlbumSelectorModal: React.FC<
+ UnlikeAlbumSelectorModalProps
+> = ({ open, onClose, albums, likedAlbumIDs, onToggleAlbum, onUnlikeAll }) => {
+ const likedCount = likedAlbumIDs.size;
+
+ return (
+ <StyledDialog open={open} onClose={onClose}>
+ <DialogWrapper>
+ <CloseButton onClick={onClose}>
+ <CloseIcon sx={{ fontSize: 20 }} />
+ </CloseButton>
+
+ <ContentContainer>
+ <IllustrationWrapper>
+ <UnlikePhotoIllustration />
+ </IllustrationWrapper>
+
+ <TitleSection>
+ <Title>Unlike photo</Title>
+ <Subtitle>
+ Select the album to unlike the photo from
+ </Subtitle>
+ </TitleSection>
+
+ <AlbumsSection>
+ <AlbumsHeader>
+ <AlbumsCount>{albums.length} Albums</AlbumsCount>
+ <UnlikeAllButton
+ onClick={likedCount > 0 ? onUnlikeAll : undefined}
+ sx={{ opacity: likedCount > 0 ? 1 : 0.5, cursor: likedCount > 0 ? "pointer" : "default" }}
+ >
+ <Typography
+ sx={(theme) => ({
+ fontWeight: 500,
+ fontSize: 14,
+ color: "#000",
+ ...theme.applyStyles("dark", {
+ color: "#fff",
+ }),
+ })}
+ >
+ Unlike all
+ </Typography>
+ <HeartFilledIcon
+ size={16}
+ color="var(--mui-palette-text-base)"
+ />
+ </UnlikeAllButton>
+ </AlbumsHeader>
+
+ <AlbumsList>
+ {albums.map((album) => {
+ const isLiked = likedAlbumIDs.has(album.id);
+ return (
+ <AlbumItem key={album.id}>
+ <AlbumName>{album.name}</AlbumName>
+ <HeartButton
+ onClick={() =>
+ onToggleAlbum(album.id, isLiked)
+ }
+ >
+ {isLiked ? (
+ <HeartFilledIcon />
+ ) : (
+ <HeartOutlineIcon />
+ )}
+ </HeartButton>
+ </AlbumItem>
+ );
+ })}
+ </AlbumsList>
+ </AlbumsSection>
+ </ContentContainer>
+ </DialogWrapper>
+ </StyledDialog>
+ );
+};
+
+// =============================================================================
+// Styled Components
+// =============================================================================
+
+const StyledDialog = styled(Dialog)(({ theme }) => ({
+ "& .MuiDialog-paper": {
+ width: 381,
+ maxWidth: "calc(100% - 32px)",
+ borderRadius: 28,
+ backgroundColor: "#fff",
+ padding: 0,
+ margin: 16,
+ overflow: "visible",
+ boxShadow: "none",
+ border: "1px solid #E0E0E0",
+ ...theme.applyStyles("dark", {
+ backgroundColor: "#1b1b1b",
+ border: "1px solid rgba(255, 255, 255, 0.18)",
+ }),
+ },
+ "& .MuiBackdrop-root": { backgroundColor: "rgba(0, 0, 0, 0.5)" },
+}));
+
+const DialogWrapper = styled(Box)(() => ({
+ position: "relative",
+ padding: "58px 24px 24px 24px",
+}));
+
+const CloseButton = styled(IconButton)(({ theme }) => ({
+ position: "absolute",
+ top: 11,
+ right: 12,
+ backgroundColor: "#FAFAFA",
+ color: "#000",
+ padding: 10,
+ "&:hover": { backgroundColor: "#F0F0F0" },
+ ...theme.applyStyles("dark", {
+ backgroundColor: "rgba(255, 255, 255, 0.12)",
+ color: "#fff",
+ "&:hover": { backgroundColor: "rgba(255, 255, 255, 0.16)" },
+ }),
+}));
+
+const ContentContainer = styled(Box)(() => ({
+ display: "flex",
+ flexDirection: "column",
+ alignItems: "center",
+ gap: 16,
+}));
+
+const IllustrationWrapper = styled(Box)(() => ({
+ display: "flex",
+ justifyContent: "center",
+ alignItems: "center",
+ marginBottom: -12,
+}));
+
+const TitleSection = styled(Box)(() => ({
+ display: "flex",
+ flexDirection: "column",
+ alignItems: "center",
+ gap: 9,
+ textAlign: "center",
+ marginBottom: 14,
+}));
+
+const Title = styled(Typography)(({ theme }) => ({
+ fontWeight: 600,
+ fontSize: 24,
+ lineHeight: "22px",
+ letterSpacing: "-0.48px",
+ color: "#000",
+ ...theme.applyStyles("dark", { color: "#fff" }),
+}));
+
+const Subtitle = styled(Typography)(({ theme }) => ({
+ fontWeight: 500,
+ fontSize: 14,
+ lineHeight: "17px",
+ color: "#666666",
+ maxWidth: 295,
+ ...theme.applyStyles("dark", { color: "rgba(255, 255, 255, 0.7)" }),
+}));
+
+const AlbumsSection = styled(Box)(({ theme }) => ({
+ width: "100%",
+ backgroundColor: "rgba(162, 162, 162, 0.12)",
+ borderRadius: 27,
+ padding: "16px 0 0 0",
+ maxHeight: 313,
+ display: "flex",
+ flexDirection: "column",
+ overflow: "hidden",
+ ...theme.applyStyles("dark", {
+ backgroundColor: "rgba(162, 162, 162, 0.12)",
+ }),
+}));
+
+const AlbumsHeader = styled(Box)(() => ({
+ display: "flex",
+ justifyContent: "space-between",
+ alignItems: "center",
+ padding: "0 16px 0 25px",
+ marginBottom: 16,
+}));
+
+const AlbumsCount = styled(Typography)(({ theme }) => ({
+ fontWeight: 500,
+ fontSize: 14,
+ lineHeight: "17px",
+ color: "#000",
+ ...theme.applyStyles("dark", { color: "#fff" }),
+}));
+
+const UnlikeAllButton = styled(Box)(({ theme }) => ({
+ display: "flex",
+ alignItems: "center",
+ gap: 10,
+ padding: 10,
+ backgroundColor: "#fff",
+ borderRadius: 14,
+ cursor: "pointer",
+ "&:hover": { backgroundColor: "#EBEBEB" },
+ ...theme.applyStyles("dark", {
+ backgroundColor: "#1b1b1b",
+ "&:hover": { backgroundColor: "#252525" },
+ }),
+}));
+
+const AlbumsList = styled(Box)(({ theme }) => ({
+ display: "flex",
+ flexDirection: "column",
+ gap: 6,
+ padding: "0 12px 12px 12px",
+ overflowY: "auto",
+ maxHeight: 241,
+ "&::-webkit-scrollbar": { width: 6 },
+ "&::-webkit-scrollbar-track": { background: "transparent" },
+ "&::-webkit-scrollbar-thumb": {
+ background: "rgba(0, 0, 0, 0.2)",
+ borderRadius: 3,
+ },
+ ...theme.applyStyles("dark", {
+ "&::-webkit-scrollbar-thumb": {
+ background: "rgba(255, 255, 255, 0.2)",
+ },
+ }),
+}));
+
+const AlbumItem = styled(Box)(({ theme }) => ({
+ display: "flex",
+ alignItems: "center",
+ justifyContent: "space-between",
+ gap: 12,
+ padding: "10px 10px 10px 16px",
+ backgroundColor: "#fff",
+ borderRadius: 16,
+ ...theme.applyStyles("dark", { backgroundColor: "#212121" }),
+}));
+
+const AlbumName = styled(Typography)(({ theme }) => ({
+ fontWeight: 500,
+ fontSize: 14,
+ lineHeight: "17px",
+ color: "#000",
+ flex: 1,
+ ...theme.applyStyles("dark", { color: "#fff" }),
+}));
+
+const HeartButton = styled(Box)(() => ({
+ width: 32,
+ height: 32,
+ display: "flex",
+ alignItems: "center",
+ justifyContent: "center",
+ backgroundColor: "rgba(8, 194, 37, 0.06)",
+ borderRadius: 9.6,
+ cursor: "pointer",
+ "&:hover": { backgroundColor: "rgba(8, 194, 37, 0.12)" },
+}));
diff --git a/web/packages/gallery/components/viewer/icons.tsx b/web/packages/gallery/components/viewer/icons.tsx
index 34bf81fed0..562a049f1d 100644
--- a/web/packages/gallery/components/viewer/icons.tsx
+++ b/web/packages/gallery/components/viewer/icons.tsx
@@ -22,6 +22,9 @@ const paths = {
error: '<path d="M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2M12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8" transform="translate(7, 5.7) scale(0.85)"',
// Custom heart outline icon (30x26 viewBox)
heart: '<path d="M12.4926 23.4794C8.64537 20.6025 1.02344 14.0254 1.02344 8.10676C1.02344 4.19475 3.89425 1.02344 7.84162 1.02344C9.88707 1.02344 11.9325 1.70526 14.6598 4.43253C17.3871 1.70526 19.4325 1.02344 21.478 1.02344C25.4253 1.02344 28.2962 4.19475 28.2962 8.10676C28.2962 14.0254 20.6743 20.6025 16.827 23.4794C15.5324 24.4474 13.7872 24.4474 12.4926 23.4794Z" stroke="white" stroke-width="2.04545" stroke-linecap="round" stroke-linejoin="round" fill="none"',
+ // Custom heart filled icon (30x26 viewBox) - green fill for liked state
+ "heart-fill":
+ '<path d="M12.4926 23.4794C8.64537 20.6025 1.02344 14.0254 1.02344 8.10676C1.02344 4.19475 3.89425 1.02344 7.84162 1.02344C9.88707 1.02344 11.9325 1.70526 14.6598 4.43253C17.3871 1.70526 19.4325 1.02344 21.478 1.02344C25.4253 1.02344 28.2962 4.19475 28.2962 8.10676C28.2962 14.0254 20.6743 20.6025 16.827 23.4794C15.5324 24.4474 13.7872 24.4474 12.4926 23.4794Z" stroke="#22c55e" stroke-width="2.04545" stroke-linecap="round" stroke-linejoin="round" fill="#22c55e"',
// Custom comment bubble icon (28x28 viewBox, scaled to match heart)
comment:
'<path d="M13.636 25.9087C16.0633 25.9087 18.4361 25.189 20.4544 23.8404C22.4726 22.4919 24.0456 20.5751 24.9745 18.3326C25.9034 16.09 26.1465 13.6224 25.6729 11.2417C25.1994 8.86105 24.0305 6.67426 22.3141 4.95788C20.5978 3.24151 18.411 2.07265 16.0303 1.5991C13.6496 1.12556 11.182 1.3686 8.93944 2.29749C6.69689 3.22639 4.78015 4.79941 3.43161 6.81765C2.08306 8.83589 1.36328 11.2087 1.36328 13.636C1.36328 15.6651 1.85419 17.5783 2.72692 19.2637L1.36328 25.9087L8.00828 24.5451C9.69373 25.4178 11.6083 25.9087 13.636 25.9087Z" stroke="white" stroke-width="2.04545" stroke-linecap="round" stroke-linejoin="round" fill="none" transform="translate(1.5, 1.5) scale(0.9)"',
@@ -109,6 +112,13 @@ export const settingsSVGPath = `<path d="M19.14 12.94c.04-.3.06-.61.06-.94 0-.32
*/
export const heartSVGPath = paths.heart;
+/**
+ * The path for the custom heart filled icon (green).
+ *
+ * Assumes `viewBox="0 0 30 26"`.
+ */
+export const heartFillSVGPath = paths["heart-fill"];
+
/**
* The path for the custom comment bubble icon.
*
diff --git a/web/packages/gallery/components/viewer/photoswipe.ts b/web/packages/gallery/components/viewer/photoswipe.ts
index 4e62b2ca1c..3335ee20c7 100644
--- a/web/packages/gallery/components/viewer/photoswipe.ts
+++ b/web/packages/gallery/components/viewer/photoswipe.ts
@@ -25,6 +25,7 @@ import {
import {
commentSVGPath,
createPSRegisterElementIconHTML,
+ heartFillSVGPath,
heartSVGPath,
settingsSVGPath,
} from "./icons";
@@ -69,6 +70,11 @@ export interface FileViewerPhotoSwipeDelegate {
* > remain in the disabled state (until the file viewer is closed).
*/
toggleFavorite: (annotatedFile: FileViewerAnnotatedFile) => Promise<void>;
+ /**
+ * Return `true` if the provided file has a green_heart reaction from the
+ * current user.
+ */
+ isLiked: (annotatedFile: FileViewerAnnotatedFile) => boolean;
/**
* Called when there is a keydown event, and our PhotoSwipe instance wants
* to know if it should ignore it or handle it.
@@ -1132,6 +1138,26 @@ export class FileViewerPhotoSwipe {
this.refreshCurrentSlideFavoriteButtonIfNeeded =
updateFavoriteButtonIfNeeded;
+ const updateLikeButtonIfNeeded = () => {
+ const heartIconFill = document.getElementById(
+ "pswp__icn-heart-fill",
+ );
+ const heartIconOutline = document.getElementById("pswp__icn-heart");
+ if (!heartIconFill || !heartIconOutline) {
+ // Early return if we're not currently being shown.
+ return;
+ }
+
+ const af = currentAnnotatedFile();
+ const isLiked = delegate.isLiked(af);
+
+ // Show fill (green) if liked, show outline (white) if not liked
+ showIf(heartIconFill, isLiked);
+ showIf(heartIconOutline, !isLiked);
+ };
+
+ this.refreshCurrentSlideLikeButtonIfNeeded = updateLikeButtonIfNeeded;
+
const handleToggleFavorite = () => void toggleFavorite();
const handleToggleFavoriteIfEnabled = () => {
@@ -1455,6 +1481,9 @@ export class FileViewerPhotoSwipe {
e.preventDefault();
onViewLikes();
});
+ // Update like button state on slide change and initially.
+ pswp.on("change", updateLikeButtonIfNeeded);
+ updateLikeButtonIfNeeded();
},
});
});
@@ -1827,6 +1856,12 @@ export class FileViewerPhotoSwipe {
* refresh would cause, e.g., the pan and zoom to be reset.
*/
refreshCurrentSlideFavoriteButtonIfNeeded: () => void;
+
+ /**
+ * Refresh the like button (heart) on the current slide, asking the
+ * delegate for the latest like state.
+ */
+ refreshCurrentSlideLikeButtonIfNeeded: () => void;
}
// Requires the following imports to register the Web components we use:
@@ -1938,7 +1973,7 @@ const bottomRightControlsHTML = () => `
<div class="pswp__caption"><p></p></div>
<div class="pswp__action-buttons">
<button class="pswp__action-button" aria-label="Like">
- <svg viewBox="0 0 30 26" fill="none">${heartSVGPath} /></svg>
+ <svg viewBox="0 0 30 26" fill="none">${heartSVGPath} id="pswp__icn-heart" />${heartFillSVGPath} id="pswp__icn-heart-fill" /></svg>
</button>
<button class="pswp__action-button pswp__action-button--comment" aria-label="Comment">
<svg viewBox="0 0 28 28" fill="none">${commentSVGPath} /></svg>
diff --git a/web/packages/new/photos/services/reaction.ts b/web/packages/new/photos/services/reaction.ts
new file mode 100644
index 0000000000..f4d7e67388
--- /dev/null
+++ b/web/packages/new/photos/services/reaction.ts
@@ -0,0 +1,154 @@
+import { decryptBox, encryptBox } from "ente-base/crypto";
+import { authenticatedRequestHeaders, ensureOk } from "ente-base/http";
+import { apiURL } from "ente-base/origins";
+import { z } from "zod";
+
+/**
+ * Fixed length for padded reaction types.
+ * All reactions are padded to this length before encryption to prevent
+ * length-based analysis of the ciphertext.
+ * Max emoji name is ~70 chars, so 100 provides a safe buffer.
+ */
+const paddedReactionLength = 100;
+
+/**
+ * Pad a reaction type to a fixed length using null bytes.
+ */
+const padReaction = (reactionType: string): string =>
+ reactionType.padEnd(paddedReactionLength, "\0");
+
+/**
+ * Remove null byte padding from a decrypted reaction type.
+ */
+const unpadReaction = (paddedReaction: string): string =>
+ paddedReaction.replace(/\0+$/, "");
+
+/**
+ * A decrypted reaction.
+ */
+export interface Reaction {
+ id: string;
+ fileID: number;
+ reactionType: string;
+ userID: number;
+ isDeleted: boolean;
+}
+
+/**
+ * Add a reaction to a file in a collection.
+ *
+ * @param collectionID The ID of the collection containing the file.
+ * @param fileID The ID of the file to react to.
+ * @param reactionType The type of reaction (e.g., "green_heart").
+ * @param collectionKey The decrypted collection key (base64 encoded).
+ * @returns The ID of the created reaction.
+ */
+export const addReaction = async (
+ collectionID: number,
+ fileID: number,
+ reactionType: string,
+ collectionKey: string,
+): Promise<string> => {
+ const { encryptedData: cipher, nonce } = await encryptBox(
+ new TextEncoder().encode(padReaction(reactionType)),
+ collectionKey,
+ );
+
+ const res = await fetch(await apiURL("/reactions"), {
+ method: "PUT",
+ headers: {
+ ...(await authenticatedRequestHeaders()),
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({ collectionID, fileID, cipher, nonce }),
+ });
+ ensureOk(res);
+ const { id } = UpsertReactionResponse.parse(await res.json());
+ return id;
+};
+
+/**
+ * Get reactions for a file in a collection.
+ *
+ * @param collectionID The ID of the collection containing the file.
+ * @param fileID The ID of the file to get reactions for.
+ * @param collectionKey The decrypted collection key (base64 encoded).
+ * @returns Array of decrypted reactions for the file.
+ */
+export const getFileReactions = async (
+ collectionID: number,
+ fileID: number,
+ collectionKey: string,
+): Promise<Reaction[]> => {
+ const res = await fetch(
+ await apiURL("/reactions/diff", {
+ collectionID,
+ fileID,
+ sinceTime: 0,
+ limit: 100,
+ }),
+ { headers: await authenticatedRequestHeaders() },
+ );
+ ensureOk(res);
+ const { reactions } = GetReactionsResponse.parse(await res.json());
+
+ const decryptedReactions: Reaction[] = [];
+ for (const reaction of reactions) {
+ // Skip deleted reactions (they have null cipher/nonce)
+ if (reaction.isDeleted || !reaction.cipher || !reaction.nonce) continue;
+ try {
+ const decryptedB64 = await decryptBox(
+ { encryptedData: reaction.cipher, nonce: reaction.nonce },
+ collectionKey,
+ );
+ const reactionType = unpadReaction(
+ new TextDecoder().decode(
+ Uint8Array.from(atob(decryptedB64), (c) => c.charCodeAt(0)),
+ ),
+ );
+ decryptedReactions.push({
+ id: reaction.id,
+ fileID: reaction.fileID,
+ reactionType,
+ userID: reaction.userID,
+ isDeleted: reaction.isDeleted,
+ });
+ } catch {
+ // Skip reactions that fail to decrypt
+ }
+ }
+ return decryptedReactions;
+};
+
+const UpsertReactionResponse = z.object({ id: z.string() });
+
+const RemoteReaction = z.object({
+ id: z.string(),
+ collectionID: z.number(),
+ fileID: z.number(),
+ userID: z.number(),
+ // cipher and nonce are missing/null for deleted reactions
+ cipher: z.string().nullish(),
+ nonce: z.string().nullish(),
+ isDeleted: z.boolean(),
+ createdAt: z.number(),
+ updatedAt: z.number(),
+});
+
+const GetReactionsResponse = z.object({
+ reactions: z.array(RemoteReaction),
+ hasMore: z.boolean(),
+});
+
+/**
+ * Delete a reaction by its ID.
+ *
+ * @param reactionID The ID of the reaction to delete.
+ */
+export const deleteReaction = async (reactionID: string): Promise<void> => {
+ const res = await fetch(await apiURL(`/reactions/${reactionID}`), {
+ method: "DELETE",
+ headers: await authenticatedRequestHeaders(),
+ });
+ ensureOk(res);
+};