diff --git a/components/RecommendButton.tsx b/components/RecommendButton.tsx index f2f94bef..00ed41a4 100644 --- a/components/RecommendButton.tsx +++ b/components/RecommendButton.tsx @@ -9,7 +9,7 @@ import { unrecommendAction, } from "app/lish/[did]/[publication]/[rkey]/Interactions/recommendAction"; import { callRPC } from "app/api/rpc/client"; -import { useToaster } from "./Toast"; +import { useSmoker, useToaster } from "./Toast"; import { OAuthErrorMessage, isOAuthSessionError } from "./OAuthError"; import { ButtonSecondary } from "./Buttons"; import { Separator } from "./Layout"; @@ -67,12 +67,13 @@ export function RecommendButton(props: { boolean | null >(null); const toaster = useToaster(); + const smoker = useSmoker(); // Use optimistic state if set, otherwise use fetched state const displayRecommended = optimisticRecommended !== null ? optimisticRecommended : hasRecommended; - const handleClick = async () => { + const handleClick = async (e: React.MouseEvent) => { if (isPending || isLoading) return; const currentlyRecommended = displayRecommended; @@ -80,10 +81,19 @@ export function RecommendButton(props: { setOptimisticRecommended(!currentlyRecommended); setCount((c) => (currentlyRecommended ? c - 1 : c + 1)); + if (!currentlyRecommended) { + smoker({ + position: { + x: e.clientX, + y: e.clientY - 16, + }, + text: