Skip to content

Real time comment indicator - #720

Merged
feruzm merged 4 commits into
developfrom
real
Mar 26, 2026
Merged

Real time comment indicator#720
feruzm merged 4 commits into
developfrom
real

Conversation

@feruzm

@feruzmferuzm commented Mar 26, 2026

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • New Features

    • Notifications: weekly-earnings notifications with USD totals and detailed/summary variants; improved payout message variants.
    • Discussions: real-time comment indicator with "new comment(s)" load buttons and auto-refresh baseline.
  • UI Updates

    • Replaced “rewards” terminology with “earnings/collect/collected” across wallet, payouts, onboarding, buttons, and labels.
    • Market copy changed to “Exchange and swap tokens instantly.”
    • Added AI Assist hint and refreshed wallet/earnings help text.

@coderabbitai

coderabbitaiBot commented Mar 26, 2026

Copy link
Copy Markdown
Contributor

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a0f250f9-459e-4a89-a058-084f9b1d184b

📥 Commits

Reviewing files that changed from the base of the PR and between 674f12e and 85f25ee.

⛔ Files ignored due to path filters (1)
  • packages/sdk/dist/browser/index.d.ts is excluded by !**/dist/**
📒 Files selected for processing (4)
  • packages/sdk/CHANGELOG.md
  • packages/sdk/package.json
  • packages/wallets/CHANGELOG.md
  • packages/wallets/package.json

📝 Walkthrough

Walkthrough

Replaced "rewards" terminology with "earnings" across UI strings, added discussion "new comments" keys and AI Assist hint, implemented polling and a new "load new comments" flow, added weekly-earnings notification types and USD fields (types + UI + WS/HTTP handling), and small wallet translation arg change.

Changes

Cohort / File(s)Summary
Localization
apps/web/src/features/i18n/locales/en-US.json
Replaced "rewards"/"claim" wording with "earnings"/"collect", updated market copy, added discussion.new-comment, discussion.new-comments, and ai-assist.hint; multiple string edits for wallet, payouts, notifications, and onboarding.
Discussion UI / Polling
apps/web/src/features/shared/discussion/index.tsx
Added 30s polling via getPostHeaderQueryOptions, loadedCountRef and newCommentCount state, handleLoadNewComments invalidates discussions query, and conditional NewCommentsButton rendering.
AI Assist UI
apps/web/src/features/shared/ai-assist/ai-assist-dialog.tsx
Inserted hint paragraph using i18next.t("ai-assist.hint") into the AI Assist modal body with styling.
Notifications: runtime logic
apps/web/src/api/notifications-ws-api.ts, apps/web/src/features/shared/notifications/notification-types/notification-payouts-type.tsx
Payout notification rendering now prefers USD-aware key when amount_usd present; added WS handling for new weekly_earnings message (short title handling).
Notifications: types & UI
apps/web/src/entities/ws-notifications.ts, packages/sdk/src/modules/notifications/types/notification.ts, apps/web/src/features/shared/notifications/notification-types/notification-weekly-earnings-type.tsx, apps/web/src/features/shared/notifications/notification-list-item.tsx
Added weekly_earnings notification interfaces (WS and API) with optional *_usd fields, updated unions, implemented NotificationWeeklyEarningsType component, and rendered it in notification list items.
Wallet transaction detail
apps/web/src/app/(dynamicPages)/profile/[username]/wallet/(token)/hbd/_components/hive-transaction-row.tsx
Extended translation args for cancel_transfer_from_savings detail to include request (request_id) so translations can display the request identifier.
Packages / Changelogs
packages/sdk/CHANGELOG.md, packages/sdk/package.json, packages/wallets/CHANGELOG.md, packages/wallets/package.json
Bumped packages/sdk to 2.0.33 and @ecency/wallets to 2.0.3; added changelog entries.

Sequence Diagram

sequenceDiagram
participant UI as Discussion UI
participant QC as QueryClient
participant API as Post Header API
participant State as Component State
rect rgba(100,200,255,0.5)
Note over QC,API: Polling (every 30s)
QC->>API: fetch post header (children count)
API-->>QC: return header (children)
end
rect rgba(200,255,100,0.5)
Note over QC,State: Detect new comments
QC->>State: provide latest children count
State->>State: compare vs loadedCountRef -> set newCommentCount
end
rect rgba(255,200,100,0.5)
Note over UI,State: Render prompt
alt newCommentCount > 0
State->>UI: show "new comments" button
end
end
rect rgba(255,150,150,0.5)
Note over UI,QC: User loads new comments
UI->>QC: invalidate discussions query (on click)
QC->>API: refetch discussions
API-->>QC: updated comments
QC->>State: update allComments, reset loadedCountRef/newCommentCount
QC->>UI: refreshed comment list
end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 I hopped through strings and swapped a word or two,

From "rewards" to "earnings", the meaning stayed true.
I listen for comments every thirty-second beat,
And nudge a tiny hint where AI and drafts meet.
A carrot-toast to changes — small, tidy, and neat.

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check nameStatusExplanationResolution
Title check⚠️ WarningThe PR title 'Real time comment indicator' is only partially related to the changeset. While the PR does add a real-time comment indicator feature (NewCommentsButton in discussion/index.tsx), the changeset also includes substantial unrelated changes: UI string rewording for earnings/rewards terminology, new notification types (weekly_earnings), and various localization updates that are not about comments.Update the title to reflect the primary scope of changes, such as 'Add real-time comment indicator and earnings terminology updates' or split into focused pull requests addressing the comment feature and localization changes separately.
Docstring Coverage⚠️ WarningDocstring coverage is 0.00% which is insufficient. The required threshold is 80.00%.Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch real

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
apps/web/src/features/shared/discussion/index.tsx (1)

175-185: Consider extracting the duplicated "load new comments" button into a reusable component.

The button markup is duplicated at Lines 175-185 and 221-231 with identical styling and logic.

♻️ Proposed refactor: Extract shared button component
+ const NewCommentsButton = useMemo(() => (+ <button+ onClick={handleLoadNewComments}+ className="w-full my-3 py-2.5 px-4 rounded-lg bg-blue-dark-sky/10 dark:bg-blue-dark-sky/20 text-blue-dark-sky hover:bg-blue-dark-sky/20 dark:hover:bg-blue-dark-sky/30 transition-colors text-sm font-medium cursor-pointer text-center"+ >+ {i18next.t(+ newCommentCount === 1 ? "discussion.new-comment" : "discussion.new-comments",+ { n: newCommentCount }+ )}+ </button>+ ), [handleLoadNewComments, newCommentCount]);+
// Then use in both places:
- {topLevelComments.length === 0 && newCommentCount > 0 && (- <button ...>...</button>- )}+ {topLevelComments.length === 0 && newCommentCount > 0 && NewCommentsButton}
// and
- {newCommentCount > 0 && (- <button ...>...</button>- )}+ {newCommentCount > 0 && NewCommentsButton}

Also applies to: 221-231

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@apps/web/src/features/shared/discussion/index.tsx` around lines 175 - 185,
The duplicated "load new comments" button markup should be extracted into a
reusable component (e.g., LoadNewCommentsButton) and used in both places instead
of repeating JSX; create a component that accepts props: newCommentCount:
number, onClick: () => void (and optional className or i18n key if needed),
render the same i18next translation logic and styling, then replace the inline
button instances that call handleLoadNewComments and reference newCommentCount
with <LoadNewCommentsButton newCommentCount={newCommentCount}
onClick={handleLoadNewComments} /> to remove duplication.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@apps/web/src/features/shared/discussion/index.tsx`:
- Around line 85-88: handleLoadNewComments currently calls
queryClient.invalidateQueries(...) and immediately calls setNewCommentCount(0),
causing a race; change it to await the invalidateQueries call (or use .then) and
only call setNewCommentCount(0) after invalidateQueries resolves for
discussionsQueryOptions.queryKey so the reset happens once invalidation
completes; update the handleLoadNewComments callback to be async (or return the
promise) and reference queryClient.invalidateQueries,
discussionsQueryOptions.queryKey, and setNewCommentCount when making this
change.
- Around line 62-83: The new-comment detection is using mismatched counts
(postHeader.children vs allComments.length); compute topLevelComments before the
effects and use topLevelComments.length consistently: initialize loadedCountRef
with parent.children or topLevelComments.length, change the postHeader effect to
compare postHeader.children (direct replies) against loadedCountRef.current
derived from topLevelComments.length, and update loadedCountRef.current =
topLevelComments.length (and setNewCommentCount(0)) in the refetch/reset effect;
alternatively, if you prefer keeping parent.children, update loadedCountRef only
after a successful refetch inside handleLoadNewComments so both comparisons use
the same metric (top-level count) and reference the symbols loadedCountRef,
postHeader, topLevelComments, allComments, and handleLoadNewComments.
---
Nitpick comments:
In `@apps/web/src/features/shared/discussion/index.tsx`:
- Around line 175-185: The duplicated "load new comments" button markup should
be extracted into a reusable component (e.g., LoadNewCommentsButton) and used in
both places instead of repeating JSX; create a component that accepts props:
newCommentCount: number, onClick: () => void (and optional className or i18n key
if needed), render the same i18next translation logic and styling, then replace
the inline button instances that call handleLoadNewComments and reference
newCommentCount with <LoadNewCommentsButton newCommentCount={newCommentCount}
onClick={handleLoadNewComments} /> to remove duplication.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1a8c0851-382c-4b11-843c-d97f9afc62fc

📥 Commits

Reviewing files that changed from the base of the PR and between 88616e9 and dad4a93.

📒 Files selected for processing (3)
  • apps/web/src/features/i18n/locales/en-US.json
  • apps/web/src/features/shared/ai-assist/ai-assist-dialog.tsx
  • apps/web/src/features/shared/discussion/index.tsx

Comment threadapps/web/src/features/shared/discussion/index.tsx
Comment on lines +85 to +88
const handleLoadNewComments = useCallback(() => {
queryClient.invalidateQueries({ queryKey: discussionsQueryOptions.queryKey });
setNewCommentCount(0);
}, [queryClient, discussionsQueryOptions.queryKey]);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Potential race condition: setNewCommentCount(0) called before query invalidation completes.

The handleLoadNewComments callback resets newCommentCount to 0 immediately, but the query invalidation is asynchronous. If the user clicks the button multiple times rapidly, or if the reset effect at Line 78-83 fires before invalidation completes, the count could be inconsistent.

🛡️ Proposed fix: Reset count only after invalidation completes
 const handleLoadNewComments = useCallback(() => {
- queryClient.invalidateQueries({ queryKey: discussionsQueryOptions.queryKey });- setNewCommentCount(0);+ queryClient.invalidateQueries({ queryKey: discussionsQueryOptions.queryKey })+ .then(() => {+ setNewCommentCount(0);+ });
}, [queryClient, discussionsQueryOptions.queryKey]);
📝 Committable suggestion

‼️IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
consthandleLoadNewComments=useCallback(()=>{
queryClient.invalidateQueries({queryKey: discussionsQueryOptions.queryKey});
setNewCommentCount(0);
},[queryClient,discussionsQueryOptions.queryKey]);
consthandleLoadNewComments=useCallback(()=>{
queryClient.invalidateQueries({queryKey: discussionsQueryOptions.queryKey})
.then(()=>{
setNewCommentCount(0);
});
},[queryClient,discussionsQueryOptions.queryKey]);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@apps/web/src/features/shared/discussion/index.tsx` around lines 85 - 88,
handleLoadNewComments currently calls queryClient.invalidateQueries(...) and
immediately calls setNewCommentCount(0), causing a race; change it to await the
invalidateQueries call (or use .then) and only call setNewCommentCount(0) after
invalidateQueries resolves for discussionsQueryOptions.queryKey so the reset
happens once invalidation completes; update the handleLoadNewComments callback
to be async (or return the promise) and reference queryClient.invalidateQueries,
discussionsQueryOptions.queryKey, and setNewCommentCount when making this
change.

@feruzm
feruzm marked this pull request as draft March 26, 2026 12:26
@feruzm
feruzm marked this pull request as ready for review March 26, 2026 12:26
@feruzm
feruzm marked this pull request as draft March 26, 2026 12:34
@feruzm
feruzm marked this pull request as ready for review March 26, 2026 12:34

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (2)
apps/web/src/features/shared/discussion/index.tsx (2)

82-94: ⚠️ Potential issue | 🟠 Major

The new-comment baseline is still using the wrong count.

Line 91 resets loadedCountRef with allComments.length, but postHeader.children is the direct-reply count. On any thread with nested replies, the badge will stop surfacing new top-level comments after the next refetch.

Suggested fix
+ const topLevelComments = useMemo(+ () =>+ allComments.filter(+ (x) => x.parent_author === parent.author && x.parent_permlink === parent.permlink+ ),+ [allComments, parent.author, parent.permlink]+ );+
useEffect(() => {
if (postHeader && postHeader.children > loadedCountRef.current) {
setNewCommentCount(postHeader.children - loadedCountRef.current);
}
}, [postHeader]);
// Reset baseline when discussions are refetched
useEffect(() => {
- if (allComments.length > 0) {- loadedCountRef.current = allComments.length;- setNewCommentCount(0);- }- }, [allComments.length]);+ loadedCountRef.current = topLevelComments.length;+ setNewCommentCount(0);+ }, [topLevelComments.length]);

Once this is fixed, please add a nested-reply regression test for the indicator path. As per coding guidelines "All new features in @ecency/web require tests".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@apps/web/src/features/shared/discussion/index.tsx` around lines 82 - 94, The
baseline for new-comment detection is being reset using allComments.length which
counts nested replies; instead reset loadedCountRef.current to the top-level
reply count (postHeader.children) so the badge tracks new direct replies
correctly—update the effect that runs on allComments change to set
loadedCountRef.current = postHeader?.children ?? loadedCountRef.current and keep
setNewCommentCount(0); also add a regression test exercising the indicator with
nested replies to ensure new top-level comments still trigger the badge
(referencing loadedCountRef, setNewCommentCount, postHeader, and allComments).

96-102: ⚠️ Potential issue | 🟡 Minor

Don’t clear the badge before the refetch finishes.

setNewCommentCount(0) and the baseline advance happen before invalidateQueries resolves, so a slow or failed refetch can hide unseen comments permanently.

Suggested fix
- const handleLoadNewComments = useCallback(() => {- if (postHeader) {- loadedCountRef.current = postHeader.children;- }- setNewCommentCount(0);- queryClient.invalidateQueries({ queryKey: discussionsQueryOptions.queryKey });- }, [queryClient, discussionsQueryOptions.queryKey, postHeader]);+ const handleLoadNewComments = useCallback(async () => {+ await queryClient.invalidateQueries({ queryKey: discussionsQueryOptions.queryKey });+ }, [queryClient, discussionsQueryOptions.queryKey]);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@apps/web/src/features/shared/discussion/index.tsx` around lines 96 - 102, The
handler handleLoadNewComments currently clears the badge and advances
loadedCountRef before the refetch completes; change it to first trigger the
refresh and only clear/update state after the refetch succeeds (or at least
after invalidate completes). Call queryClient.invalidateQueries({ queryKey:
discussionsQueryOptions.queryKey }) and in its promise continuation (then/catch)
update loadedCountRef.current = postHeader.children and call
setNewCommentCount(0) on success (and avoid clearing on failure or handle
errors), leaving setNewCommentCount and loadedCountRef updates tied to the
resolution of invalidateQueries rather than before it.
🧹 Nitpick comments (2)
apps/web/src/features/shared/discussion/index.tsx (1)

37-45: Extract NewCommentsButton props into an interface.

This is the only new inline object shape in the file; a named interface keeps it aligned with the repo’s TypeScript convention.

Suggested cleanup
-function NewCommentsButton({ count, onClick }: { count: number; onClick: () => void }) {+interface NewCommentsButtonProps {+ count: number;+ onClick: () => void;+}++function NewCommentsButton({ count, onClick }: NewCommentsButtonProps) {

As per coding guidelines "Prefer interface for defining object shapes in TypeScript".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@apps/web/src/features/shared/discussion/index.tsx` around lines 37 - 45,
Extract the inline prop type for NewCommentsButton into a named interface:
create an interface NewCommentsButtonProps { count: number; onClick: () => void
} and then update the component signature from function NewCommentsButton({
count, onClick }: { count: number; onClick: () => void }) to function
NewCommentsButton(props: NewCommentsButtonProps) or function NewCommentsButton({
count, onClick }: NewCommentsButtonProps); keep the same prop names (count,
onClick) and usage inside the component.
apps/web/src/entities/ws-notifications.ts (1)

145-152: Optional cleanup: extract shared USD breakdown shape to avoid drift.

Both weekly-earnings interfaces repeat the same USD fields. A small shared interface keeps them synchronized over time.

♻️ Proposed refactor
+interface WeeklyEarningsUsdBreakdown {+ total_usd?: string;+ author_usd?: string;+ curation_usd?: string;+}+
export interface WsWeeklyEarningsNotification extends BaseWsNotification {
type: "weekly_earnings";
extra?: {
- total_usd?: string;- author_usd?: string;- curation_usd?: string;- };+ } & WeeklyEarningsUsdBreakdown;
}
export interface ApiWeeklyEarningsNotification extends BaseAPiNotification {
type: "weekly_earnings";
- total_usd?: string;- author_usd?: string;- curation_usd?: string;-}+} & WeeklyEarningsUsdBreakdown;

Also applies to: 311-316

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@apps/web/src/entities/ws-notifications.ts` around lines 145 - 152, Extract
the repeated USD fields into a single shared interface (e.g.,
WeeklyEarningsUsdBreakdown or UsdBreakdown) and replace the inline extra?
structures in WsWeeklyEarningsNotification and the other weekly-earnings
interface (the one with the same total_usd/author_usd/curation_usd fields) to
reference that shared type; update any import/exports or usages to use the new
interface name so both notifications stay synchronized.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@apps/web/src/features/shared/notifications/notification-types/notification-weekly-earnings-type.tsx`:
- Around line 10-22: Add component tests for NotificationWeeklyEarningsType to
cover both message branches: render the component with a notification object
that includes total_usd, author_usd, and curation_usd to assert the full
"notification.weekly-earnings" output, and render it with only total_usd
(author_usd or curation_usd missing/undefined) to assert the fallback
"notification.weekly-earnings-short" output. Use the same i18next mocking used
across the codebase (or mock i18next.t) and React Testing Library to render
NotificationWeeklyEarningsType and assert the expected translated text appears
when hasBreakdown (the hasBreakdown logic checking notification.author_usd &&
notification.curation_usd) is true and when it is false. Ensure tests live
alongside the component tests and name them to indicate both branches are
covered.
---
Duplicate comments:
In `@apps/web/src/features/shared/discussion/index.tsx`:
- Around line 82-94: The baseline for new-comment detection is being reset using
allComments.length which counts nested replies; instead reset
loadedCountRef.current to the top-level reply count (postHeader.children) so the
badge tracks new direct replies correctly—update the effect that runs on
allComments change to set loadedCountRef.current = postHeader?.children ??
loadedCountRef.current and keep setNewCommentCount(0); also add a regression
test exercising the indicator with nested replies to ensure new top-level
comments still trigger the badge (referencing loadedCountRef,
setNewCommentCount, postHeader, and allComments).
- Around line 96-102: The handler handleLoadNewComments currently clears the
badge and advances loadedCountRef before the refetch completes; change it to
first trigger the refresh and only clear/update state after the refetch succeeds
(or at least after invalidate completes). Call queryClient.invalidateQueries({
queryKey: discussionsQueryOptions.queryKey }) and in its promise continuation
(then/catch) update loadedCountRef.current = postHeader.children and call
setNewCommentCount(0) on success (and avoid clearing on failure or handle
errors), leaving setNewCommentCount and loadedCountRef updates tied to the
resolution of invalidateQueries rather than before it.
---
Nitpick comments:
In `@apps/web/src/entities/ws-notifications.ts`:
- Around line 145-152: Extract the repeated USD fields into a single shared
interface (e.g., WeeklyEarningsUsdBreakdown or UsdBreakdown) and replace the
inline extra? structures in WsWeeklyEarningsNotification and the other
weekly-earnings interface (the one with the same
total_usd/author_usd/curation_usd fields) to reference that shared type; update
any import/exports or usages to use the new interface name so both notifications
stay synchronized.
In `@apps/web/src/features/shared/discussion/index.tsx`:
- Around line 37-45: Extract the inline prop type for NewCommentsButton into a
named interface: create an interface NewCommentsButtonProps { count: number;
onClick: () => void } and then update the component signature from function
NewCommentsButton({ count, onClick }: { count: number; onClick: () => void }) to
function NewCommentsButton(props: NewCommentsButtonProps) or function
NewCommentsButton({ count, onClick }: NewCommentsButtonProps); keep the same
prop names (count, onClick) and usage inside the component.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1b5e6b82-9441-48ab-a170-90fec7b12f24

📥 Commits

Reviewing files that changed from the base of the PR and between dad4a93 and 674f12e.

📒 Files selected for processing (9)
  • apps/web/src/api/notifications-ws-api.ts
  • apps/web/src/app/(dynamicPages)/profile/[username]/wallet/(token)/hbd/_components/hive-transaction-row.tsx
  • apps/web/src/entities/ws-notifications.ts
  • apps/web/src/features/i18n/locales/en-US.json
  • apps/web/src/features/shared/discussion/index.tsx
  • apps/web/src/features/shared/notifications/notification-list-item.tsx
  • apps/web/src/features/shared/notifications/notification-types/notification-payouts-type.tsx
  • apps/web/src/features/shared/notifications/notification-types/notification-weekly-earnings-type.tsx
  • packages/sdk/src/modules/notifications/types/notification.ts

Comment on lines +10 to +22
export function NotificationWeeklyEarningsType({ sourceLink, notification }: Props) {
const totalUsd = notification.total_usd ?? "0";
const authorUsd = notification.author_usd ?? "0";
const curationUsd = notification.curation_usd ?? "0";

const hasBreakdown = notification.author_usd && notification.curation_usd;
const message = hasBreakdown
? i18next.t("notification.weekly-earnings", {
total: totalUsd,
author: authorUsd,
curation: curationUsd
})
: i18next.t("notification.weekly-earnings-short", { total: totalUsd });

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Add coverage for both weekly-earnings message branches.

This renderer now has two user-visible paths (notification.weekly-earnings vs notification.weekly-earnings-short), but the change set doesn’t include a spec for either branch. A small component test here would lock down the fallback when the breakdown is missing.

As per coding guidelines "All new features in @ecency/web require tests".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@apps/web/src/features/shared/notifications/notification-types/notification-weekly-earnings-type.tsx`
around lines 10 - 22, Add component tests for NotificationWeeklyEarningsType to
cover both message branches: render the component with a notification object
that includes total_usd, author_usd, and curation_usd to assert the full
"notification.weekly-earnings" output, and render it with only total_usd
(author_usd or curation_usd missing/undefined) to assert the fallback
"notification.weekly-earnings-short" output. Use the same i18next mocking used
across the codebase (or mock i18next.t) and React Testing Library to render
NotificationWeeklyEarningsType and assert the expected translated text appears
when hasBreakdown (the hasBreakdown logic checking notification.author_usd &&
notification.curation_usd) is true and when it is false. Ensure tests live
alongside the component tests and name them to indicate both branches are
covered.

@feruzmferuzm added the patch Bug fixes and patches (1.0.0 → 1.0.1) label Mar 26, 2026
@feruzm
feruzm merged commit 441ea91 into developMar 26, 2026
1 check was pending
@feruzm
feruzm deleted the real branch March 26, 2026 13:04
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patchBug fixes and patches (1.0.0 → 1.0.1)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@feruzm