Skip to content
This repository was archived by the owner on Jul 14, 2026. It is now read-only.

♻️ Use Snackbar from Context#305

Merged
Sophie235 merged 1 commit into
mainfrom
feature/unify-snackbar
Jul 13, 2026
Merged

♻️ Use Snackbar from Context#305
Sophie235 merged 1 commit into
mainfrom
feature/unify-snackbar

Conversation

@Sophie235

Copy link
Copy Markdown
Contributor

PR removed custom Snackbar and use context instead

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@Sophie235, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 51 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 79e944af-45dc-4754-ada1-c3df1d15a435

📥 Commits

Reviewing files that changed from the base of the PR and between 7c90a8c and e33decd.

📒 Files selected for processing (1)
  • ecoscan_app/components/alternatives/AlternativesTab.tsx

Walkthrough

AlternativesTab now uses the shared SnackbarContext to display “EAN kopiert!” after copying an EAN. Local snackbar state and inline rendering were removed; list, key extraction, loading, and empty-state behavior remain unchanged.

Changes

Alternatives snackbar integration

Layer / File(s) Summary
Shared snackbar copy feedback
ecoscan_app/components/alternatives/AlternativesTab.tsx
AlternativesTab uses useSnackbar() and calls showSuccess from the copy handler while preserving the existing FlatList and empty-state behavior.

Estimated code review effort: 2 (Simple) | ~10 minutes

Poem

I’m a rabbit hopping light,
Copying EANs just right.
Shared snackbar, bright and neat,
“EAN kopiert!”—a treat!
No local state to tug my ear.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring 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 (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: switching Snackbar usage to context.
Description check ✅ Passed The description is related to the change and accurately notes the Snackbar refactor to context.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/unify-snackbar

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
ecoscan_app/components/alternatives/AlternativesTab.tsx (1)

21-33: 🚀 Performance & Scalability | 🔵 Trivial | 💤 Low value

Consider memoizing the onCopy callback.

showSuccess from SnackbarContext is stable (wrapped in useCallback), but the inline arrow () => showSuccess("EAN kopiert!") creates a new function reference on every render. Since AlternativeCard lists onCopy as a useCallback dependency, its handleCopyToClipboard is unnecessarily recreated each render. Wrapping in useCallback with [showSuccess] keeps it stable.

♻️ Optional: stabilize the onCopy callback
 export default function AlternativesTab({
   alternatives,
   loadingEan,
 }: AlternativesTabProps) {
   const { showSuccess } = useSnackbar();
 
+  const handleCopy = useCallback(() => {
+    showSuccess("EAN kopiert!");
+  }, [showSuccess]);
+
   return (
     <FlatList
       data={alternatives}
       keyExtractor={(item) => item.ean}
       renderItem={({ item }) => (
         <AlternativeCard
           key={item.ean}
           name={item.name}
           ean={item.ean}
           imageUrl={item.imageUrl}
-          onCopy={() => showSuccess("EAN kopiert!")}
+          onCopy={handleCopy}
         />
       )}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@ecoscan_app/components/alternatives/AlternativesTab.tsx` around lines 21 -
33, Memoize the copy handler in AlternativesTab using useCallback with
showSuccess as its dependency, then pass that stable callback to AlternativeCard
instead of creating an inline arrow in renderItem.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@ecoscan_app/components/alternatives/AlternativesTab.tsx`:
- Around line 21-33: Memoize the copy handler in AlternativesTab using
useCallback with showSuccess as its dependency, then pass that stable callback
to AlternativeCard instead of creating an inline arrow in renderItem.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2e8894eb-a619-4f70-a4e9-5f125bdd0523

📥 Commits

Reviewing files that changed from the base of the PR and between 0087ab7 and 7c90a8c.

📒 Files selected for processing (1)
  • ecoscan_app/components/alternatives/AlternativesTab.tsx

@Sophie235 Sophie235 force-pushed the feature/unify-snackbar branch from 7c90a8c to e33decd Compare July 13, 2026 07:40
@Sophie235 Sophie235 merged commit bff765b into main Jul 13, 2026
10 checks passed
@Sophie235 Sophie235 deleted the feature/unify-snackbar branch July 13, 2026 18:34
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants