refactor(home): drop the isReloading guard that could never fire - #935
Merged
Conversation
`performReload` set `isReloading = true` on entry and back to false before returning, and `onTransactionStatusChanged` checked the flag from inside `queue.async`. Both run on the same serial `queue`, and `performReload` has a single caller — also inside `queue.async` — with no early return, `await`, or re-dispatch between the two assignments. So the reload always finished, and reset the flag, before the guard could run: it never observed `true`. That made the accompanying comment wrong in the way guardrail #2 forbids. It claimed to "skip incremental updates while a full reload is in progress to prevent race conditions that could cause missing transactions" — describing protection the code did not provide. A reader auditing the feed for lost transactions would have credited a guard that does nothing. Removes the property, all three assignments, and the guard. Two neighbouring comments are trimmed so they no longer describe a flag that is gone. No behavior change: the guard's body was unreachable. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthrough
ChangesHome reload state
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Raised by CodeRabbit on #931, and deliberately left out of that PR to keep a CrowdNode-focused change from expanding into pre-existing develop code.
The problem
HomeViewModel.isReloadingis dead.performReloadsets ittrueon entry and back tofalsebefore returning;onTransactionStatusChangedthen checks it from insidequeue.async. Both run on the same serialqueue, so the reload has always completed — and reset the flag — before the guard can run. It never observestrue.The comment on that guard claimed it would
which describes protection that does not exist. That is the failure mode CLAUDE.md guardrail #2 exists to prevent: anyone auditing the feed for dropped transactions would have credited a guard that does nothing.
Verification of the serial-queue premise
Checked before deleting, since a concurrent queue would have made the guard live:
queueisDispatchQueue(label: "HomeViewModel", qos: .userInitiated)— noattributes: .concurrent, so serial.performReloadhas exactly one caller, itself insidequeue.async.return,await, or re-dispatch between thetrueandfalseassignments — the body is synchronous, so the flag cannot leak past the call.isReloadingis referenced nowhere outsideHomeViewModel.swift.Changes
Removes the property, all three assignments (
performReloadentry/exit and the network-change handler), and the guard with its comment. Two neighbouring comments are trimmed so they stop describing a flag that no longer exists:Reset load tracking flags→Reset load trackingFix #2 & #3: Mark initial load complete and clear reload flag→Fix #2: Mark initial load completeNo behavior change — the guard's body was unreachable.
Testing
Clean
dashpaybuild,** BUILD SUCCEEDED **:The unit-test target is still broken on develop (pre-existing), so the build is the verification standard here.
🤖 Generated with Claude Code
Summary by CodeRabbit