Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion desktop/src/features/home/ui/InboxMessageRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ export function InboxMessageRow({
() => toTimelineMessage(message),
[message],
);
const [badgeBurstEmoji, setBadgeBurstEmoji] = React.useState<string | null>(
null,
);
const {
reactions,
canToggle: canToggleReactions,
Expand Down Expand Up @@ -92,11 +95,13 @@ export function InboxMessageRow({
onReactionSelect={
canToggleReactions ? handleReactionSelect : undefined
}
onReactionBadgeBurstRequest={
reactionPending ? undefined : setBadgeBurstEmoji
}
onReply={
canReply ? () => onSelectReplyTarget(message) : undefined
}
reactionErrorMessage={reactionErrorMessage}
reactionPending={reactionPending}
reactions={reactions}
/>
</div>
Expand Down Expand Up @@ -134,6 +139,12 @@ export function InboxMessageRow({
onSelect={(emoji) => {
void handleReactionSelect(emoji);
}}
burstEmojiOnRender={badgeBurstEmoji}
onBurstEmojiRendered={(emoji) => {
setBadgeBurstEmoji((current) =>
current === emoji ? null : current,
);
}}
pending={reactionPending}
reactions={reactions}
/>
Expand Down
23 changes: 14 additions & 9 deletions desktop/src/features/messages/ui/MessageActionBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ import {
DropdownMenuSeparator,
DropdownMenuTrigger,
} from "@/shared/ui/dropdown-menu";
import { isPositiveEmojiParticle } from "@/shared/ui/EmojiBurstProvider";
import { Popover, PopoverContent, PopoverTrigger } from "@/shared/ui/popover";
import { Spinner } from "@/shared/ui/spinner";
import { Tooltip, TooltipContent, TooltipTrigger } from "@/shared/ui/tooltip";

function copyToClipboard(text: string, successMessage: string) {
Expand Down Expand Up @@ -263,12 +263,12 @@ export function MessageActionBar({
onEdit,
onFollowThread,
onMarkUnread,
onReactionBadgeBurstRequest,
onReactionSelect,
onReply,
onUnfollowThread,
reactionErrorMessage = null,
reactions,
reactionPending = false,
isFollowingThread,
}: {
/** Channel UUID — required for the "Copy link" action; when omitted the
Expand All @@ -279,12 +279,12 @@ export function MessageActionBar({
onEdit?: (message: TimelineMessage) => void;
onFollowThread?: (message: TimelineMessage) => void;
onMarkUnread?: (message: TimelineMessage) => void;
onReactionBadgeBurstRequest?: (emoji: string) => void;
onReactionSelect?: (emoji: string) => Promise<void>;
onReply?: (message: TimelineMessage) => void;
onUnfollowThread?: (message: TimelineMessage) => void;
reactionErrorMessage?: string | null;
reactions: TimelineReaction[];
reactionPending?: boolean;
isFollowingThread?: boolean;
}) {
const [isReactionPickerOpen, setIsReactionPickerOpen] = React.useState(false);
Expand All @@ -307,6 +307,10 @@ export function MessageActionBar({
const selectedReactionCount = reactions.filter(
(reaction) => reaction.reactedByCurrentUser,
).length;
const wouldAddReaction = (emoji: string) =>
!reactions.some(
(reaction) => reaction.emoji === emoji && reaction.reactedByCurrentUser,
);

return (
<div
Expand Down Expand Up @@ -334,7 +338,6 @@ export function MessageActionBar({
aria-label="Open reactions"
className="h-6 w-6 rounded-full p-0"
data-testid={`react-message-${message.id}`}
disabled={reactionPending}
size="sm"
type="button"
variant={
Expand All @@ -343,11 +346,7 @@ export function MessageActionBar({
: "ghost"
}
>
{reactionPending ? (
<Spinner className="h-3 w-3" />
) : (
<SmilePlus className="h-3 w-3" />
)}
<SmilePlus className="h-3 w-3" />
</Button>
</PopoverTrigger>
</TooltipTrigger>
Expand All @@ -374,6 +373,12 @@ export function MessageActionBar({
}
// `value` is already a `native` glyph or a `:shortcode:` for
// custom emoji; the toggle mutation resolves the URL.
if (
wouldAddReaction(value) &&
isPositiveEmojiParticle(value)
) {
onReactionBadgeBurstRequest?.(value);
}
void onReactionSelect(value).finally(() => {
setIsReactionPickerOpen(false);
});
Expand Down
Loading