feat: add shake gesture for ticket QR access#649
Conversation
|
Warning Review limit reached
More reviews will be available in 50 minutes and 25 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the 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 credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. 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, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds a shake-gesture interaction to ChangesShake Gesture for Ticket Navigation
Attendance Points Reward
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 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.
Actionable comments posted: 3
🤖 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.
Inline comments:
In `@app/package.json`:
- Around line 1-118: The package.json file is not properly formatted according
to Prettier standards, causing CI warnings. Run the format command using the
prettier script defined in the scripts section of this package.json (the
"format" script) to automatically reformat and normalize the JSON output, then
commit the normalized file to clear the CI warnings.
In `@app/src/hooks/useShakeGesture.js`:
- Around line 5-21: The useEffect dependency on onShake causes the effect to
recreate whenever the onShake callback reference changes, which resets the
lastShake variable (line 6) and bypasses the 1-second cooldown. To preserve the
cooldown state across re-renders and effect recreations, convert the lastShake
variable from a regular let declaration to a useRef hook, so that the timestamp
persists even when the effect tears down and rebuilds due to onShake identity
changes.
In `@app/src/screens/WalletScreen.js`:
- Around line 27-31: In the useShakeGesture callback, add a check to return
early if the loading state is true before checking if tickets.length is empty.
This prevents the "No Tickets" alert from being shown while data is still being
fetched, since tickets starts as an empty array by default. Add a condition like
if (loading) return; before the existing if (!tickets.length) check in the shake
gesture handler.
🪄 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: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: ee508c48-98da-4884-a888-07987054a33d
⛔ Files ignored due to path filters (1)
app/package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (4)
app/package.jsonapp/src/hooks/useShakeGesture.jsapp/src/screens/WalletScreen.jscloud-functions/src/attendanceStreak.ts
|
resolev the issues by coderabbit suggestions |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
app/src/hooks/useShakeGesture.js (1)
5-21:⚠️ Potential issue | 🔴 CriticalMove
useRefto the top level of the hook.Line 6 calls
useRefinside theuseEffectcallback, which violates React Hooks rules (hooks must be called at the top level). Additionally, the effect dependency ononShakecauses unnecessary subscription recreations wheneverWalletScreenpasses a new inline callback. Fix by movinglastShakeRefout of the effect and storingonShakein a ref to keep the subscription stable.Proposed fix
export default function useShakeGesture(onShake) { + const lastShakeRef = useRef(0); + const onShakeRef = useRef(onShake); + + useEffect(() => { + onShakeRef.current = onShake; + }, [onShake]); + useEffect(() => { - const lastShakeRef = useRef(0); - Accelerometer.setUpdateInterval(100); const subscription = Accelerometer.addListener(({ x, y, z }) => { const acceleration = Math.sqrt(x * x + y * y + z * z); const now = Date.now(); if (acceleration > 2.2 && now - lastShakeRef.current > 1000) { lastShakeRef.current = now; - onShake?.(); + onShakeRef.current?.(); } }); return () => subscription.remove(); - }, [onShake]); + }, []); }🤖 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 `@app/src/hooks/useShakeGesture.js` around lines 5 - 21, In the useShakeGesture hook, move the lastShakeRef declaration out of the useEffect callback to the top level of the hook, as calling useRef inside useEffect violates React Hooks rules. Additionally, create another useRef at the hook's top level to store the onShake callback, then update the useEffect to reference this ref instead of using onShake directly in the callback. This keeps the Accelerometer subscription stable and removes the unnecessary dependency on onShake in the effect's dependency array. Update the effect to call onShakeRef.current?.() instead of onShake?.() and include only the necessary dependencies in the array.Source: Linters/SAST tools
🤖 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.
Outside diff comments:
In `@app/src/hooks/useShakeGesture.js`:
- Around line 5-21: In the useShakeGesture hook, move the lastShakeRef
declaration out of the useEffect callback to the top level of the hook, as
calling useRef inside useEffect violates React Hooks rules. Additionally, create
another useRef at the hook's top level to store the onShake callback, then
update the useEffect to reference this ref instead of using onShake directly in
the callback. This keeps the Accelerometer subscription stable and removes the
unnecessary dependency on onShake in the effect's dependency array. Update the
effect to call onShakeRef.current?.() instead of onShake?.() and include only
the necessary dependencies in the array.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: eda85cad-a384-4b8c-83e7-fafea9451ed8
📒 Files selected for processing (2)
app/src/hooks/useShakeGesture.jsapp/src/screens/WalletScreen.js
🚧 Files skipped from review as they are similar to previous changes (1)
- app/src/screens/WalletScreen.js
|
|
Sir, @roshankumar0036singh, I have resolved the errors please once have an eye. |



Summary
Implemented a shake gesture feature that allows users to quickly access their ticket QR code.
Changes Made
useShakeGesturehook usingexpo-sensorsWalletScreenexpo-sensorsdependencyNotes
The repository structure has changed since the issue was opened and the referenced
HomeScreen.tsxno longer exists. The feature was implemented inWalletScreen, which is the current entry point for accessing ticket QR codes.Summary by CodeRabbit