feat(wallet): poll 2s/30s then focus+visibilitychange for mid-session Freighter install detection (#41)#262
Conversation
|
@collinsezedike is attempting to deploy a commit to the ezedikeevan's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@collinsezedike Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
| @@ -0,0 +1,166 @@ | |||
| import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest' | |||
| import { renderHook, waitFor, act } from '@testing-library/react' | |||
ezedike-evan
left a comment
There was a problem hiding this comment.
The implementation is exactly right: 2s early polling for the first 30s, then zero-cost event-driven detection via `focus` + `visibilitychange`, with `WatchWalletChanges` running in parallel for account/network changes. The three-timer cleanup in the return function is correct (early interval, early timeout, watcher, fallback interval, and both event listeners all removed). `onVisibilityDetect` is properly hoisted outside `init()` so `removeEventListener` matches the same reference. The 7 new tests in `freighter-detect.spec.tsx` cover every path including the "no polls after 30s without an event" invariant.
Ready to merge — but this branch is stacked on #261 and cannot land until #261 is rebased and merged first. Once #261 is merged into `main`, rebase this branch on the updated `main` and push — it will merge cleanly.
```bash
After #261 is merged:
git fetch origin
git rebase origin/main
git push --force-with-lease
```
|
Approved and ready to land — waiting on #261 to merge first since this branch is stacked on it. Once #261 is merged into `main`, rebase this branch on the updated `main` and push: ```bash No code changes needed — just the rebase. |
…k, disable Execute on wrong network (ezedike-evan#42)
… Freighter install detection (ezedike-evan#41)
…r leak on remount
d9740dd to
8034d94
Compare
Summary
window focus+document visibilitychangelisteners instead (zero-cost ongoing detection)WatchWalletChangessubscription runs in parallel for account/network change tracking — the two concerns are independenttests/freighter-detect.spec.tsxcovering early-poll detection, event-driven detection, and cleanupTest plan
Closes #41