Skip to content

feat: pnl api image cards#2060

Merged
dwjanus merged 3 commits intomainfrom
dwj/generated-pnl-image
Jan 28, 2026
Merged

feat: pnl api image cards#2060
dwjanus merged 3 commits intomainfrom
dwj/generated-pnl-image

Conversation

@dwjanus
Copy link
Contributor

@dwjanus dwjanus commented Jan 27, 2026

Changes

  • implement pnl image api route and replace UI

Screenshots/Recordings (Optional)

Screenshot 2026-01-27 at 1 30 59 PM

@dwjanus dwjanus requested a review from a team as a code owner January 27, 2026 18:31
@vercel
Copy link

vercel bot commented Jan 27, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
v4-staging Ready Ready Preview, Comment Jan 28, 2026 4:27am
v4-testnet Ready Ready Preview, Comment Jan 28, 2026 4:27am

Request Review

Comment on lines 56 to 57
const isCopying = useRef(false);
const isSharing = useRef(false);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using a ref here is probably not the correct move, especially if you want it to be used to display loading state in the buttons. If you are using a ref as a mutex with no UI changes this is ok.

await copyBlobToClipboard(pnlImage);
setIsCopied(true);
setTimeout(() => setIsCopied(false), 2000);
isCopying.current = false;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this mutex is never unlocked if their is an error copying to clipboard. We should wrap this in a try/catch and add a finally to unlock the state. If you switch the useRef to useState

if (isCopying || !pnlImage) return;

try {
  setIsCopying(true);
  ...
} catch(err) {
  setError(err);
} finally {
  setIsCopying(false);
}

Comment on lines 81 to 100
const sharePnlImage = async () => {
if (isSharing.current || !pnlImage) return;
isSharing.current = true;
await copyBlobToClipboard(pnlImage);
setIsCopied(true);
setTimeout(() => setIsCopied(false), 2000);

triggerTwitterIntent({
text: `${stringGetter({
key: STRING_KEYS.TWEET_MARKET_POSITION,
params: {
MARKET: symbol,
},
})}\n\n#bonk_trade #${symbol}\n[${stringGetter({ key: STRING_KEYS.TWEET_PASTE_IMAGE_AND_DELETE_THIS })}]`,
related: 'bonk_inu',
});
isSharing.current = false;

dispatch(closeDialog());
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comments here as above.

action={ButtonAction.Primary}
slotLeft={<Icon iconName={IconName.SocialX} />}
onClick={() => {
track(AnalyticsEvents.SharePnlShared({ asset: assetId }));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can prob be moved to the sharePnlImage function

action={ButtonAction.Secondary}
slotLeft={<Icon iconName={isCopied ? IconName.Check : IconName.Copy} />}
onClick={() => {
track(AnalyticsEvents.SharePnlCopied({ asset: assetId }));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be moved to copyPnlImage()

onClick={() => copyPnlImage()}
state={{
isLoading: !!isCopying.current,
isLoading: !!isCopying,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for the !!

onClick={() => sharePnlImage()}
state={{
isLoading: !!isSharing.current,
isLoading: !!isSharing,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for !!

track(AnalyticsEvents.SharePnlShared({ asset: assetId }));
sharePnlImage();
}}
onClick={() => sharePnlImage()}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

onClick={sharePnlImage}

track(AnalyticsEvents.SharePnlCopied({ asset: assetId }));
copyPnlImage();
}}
onClick={() => copyPnlImage()}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

onClick={copyPnlImage}

@dwjanus dwjanus merged commit 867bfed into main Jan 28, 2026
10 checks passed
@dwjanus dwjanus deleted the dwj/generated-pnl-image branch January 28, 2026 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants