fix(notifications): render body from payload or Slack JSON#2889
fix(notifications): render body from payload or Slack JSON#2889adityathebe wants to merge 2 commits intomainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
WalkthroughDetail-fetch on row click now checks Changes
Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/components/Notifications/NotificationSendHistory/NotificationDetails.tsx (1)
81-87: Consider merging the two useMemos into one.
slackBodydepends solely onlegacySlackMessagewhich is already memoized one line above. You could compute the markdown string directly inside the firstuseMemoand drop this second one, reducing the number of hooks and intermediate variables.♻️ Optional: inline into the first useMemo
- const legacySlackMessage = useMemo<SlackMessage | undefined>(() => { + const slackBody = useMemo<string | undefined>(() => { if (bodyMarkdown || !legacyBody) { return undefined; } + let msg: SlackMessage | undefined; try { const parsed = JSON.parse(legacyBody.trim()) as | SlackMessage | SlackMessage[]; if (Array.isArray(parsed)) { const [firstMessage] = parsed; - return Array.isArray(firstMessage?.blocks) ? firstMessage : undefined; + msg = Array.isArray(firstMessage?.blocks) ? firstMessage : undefined; + } else { + msg = Array.isArray(parsed?.blocks) ? parsed : undefined; } - return Array.isArray(parsed?.blocks) ? parsed : undefined; } catch { return undefined; } + return msg ? blockKitToMarkdown(msg) : undefined; }, [bodyMarkdown, legacyBody]); - - const slackBody = useMemo(() => { - if (!legacySlackMessage) { - return undefined; - } - return blockKitToMarkdown(legacySlackMessage); - }, [legacySlackMessage]);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/components/Notifications/NotificationSendHistory/NotificationDetails.tsx` around lines 81 - 87, The slackBody useMemo duplicates work because it depends only on legacySlackMessage which is already memoized; merge the conversion into the existing useMemo that produces legacySlackMessage by calling blockKitToMarkdown(legacySlackMessage) there (or compute markdown from the same source) and remove the second useMemo and intermediate slackBody variable; update any references to slackBody to use the newly computed markdown variable from the original useMemo (referencing useMemo, legacySlackMessage, slackBody, and blockKitToMarkdown).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In
`@src/components/Notifications/NotificationSendHistory/NotificationDetails.tsx`:
- Around line 81-87: The slackBody useMemo duplicates work because it depends
only on legacySlackMessage which is already memoized; merge the conversion into
the existing useMemo that produces legacySlackMessage by calling
blockKitToMarkdown(legacySlackMessage) there (or compute markdown from the same
source) and remove the second useMemo and intermediate slackBody variable;
update any references to slackBody to use the newly computed markdown variable
from the original useMemo (referencing useMemo, legacySlackMessage, slackBody,
and blockKitToMarkdown).
ℹ️ Review info
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/components/Notifications/NotificationSendHistory.tsxsrc/components/Notifications/NotificationSendHistory/NotificationDetails.tsx
1280b11 to
a038d03
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@src/components/Notifications/NotificationSendHistory/NotificationDetails.tsx`:
- Around line 70-73: In NotificationDetails.tsx the Array.isArray(parsed) branch
only checks parsed[0] for blocks and returns undefined if it lacks blocks;
change this to scan the parsed array for the first element whose blocks is an
array (e.g., use parsed.find(item => Array.isArray(item?.blocks))) and return
that element (or undefined if none found) so later markdown conversion receives
the first valid Slack message rather than only index 0.
ℹ️ Review info
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/components/Notifications/NotificationSendHistory.tsxsrc/components/Notifications/NotificationSendHistory/NotificationDetails.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
- src/components/Notifications/NotificationSendHistory.tsx
src/components/Notifications/NotificationSendHistory/NotificationDetails.tsx
Show resolved
Hide resolved
a038d03 to
fc3771c
Compare
closes: #2887
Summary by CodeRabbit
Bug Fixes
UI / Styling