fix: fixed the old social bindings resurfacing when they have already…#1064
fix: fixed the old social bindings resurfacing when they have already…#1064Sahil2004 wants to merge 1 commit into
Conversation
📝 WalkthroughWalkthroughAdded a ChangesStale Social Binding Cleanup
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant SocialBindingDrawer
participant socialBindingUtils as socialBinding.ts
participant GraphQLBackend
SocialBindingDrawer->>SocialBindingDrawer: initFromVault()
SocialBindingDrawer->>socialBindingUtils: pruneBoundSignerDocs(gqlUrl, ename)
socialBindingUtils->>GraphQLBackend: fetch social_connection docs
GraphQLBackend-->>socialBindingUtils: edges
socialBindingUtils->>socialBindingUtils: collectBoundSigners(edges)
socialBindingUtils->>GraphQLBackend: deleteSocialBindingDoc(stale docs)
socialBindingUtils-->>SocialBindingDrawer: deleted count
SocialBindingDrawer->>SocialBindingDrawer: startPolling()
Related issues: Suggested reviewers: Talha 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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.
🧹 Nitpick comments (1)
infrastructure/eid-wallet/src/lib/utils/socialBinding.ts (1)
606-622: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚖️ Poor tradeoffOptional: the fetch +
collectBoundSigners+ filter block largely duplicatesfetchUnsignedSocialDocs.Both functions run the same query, compute
boundSigners, and apply the sametype/subject/alreadySigned/originator ∈ boundSignerspredicate —pruneBoundSignerDocsonly inverts the last condition to select stale docs rather than exclude them. Extracting a sharedisStaleBoundSignerDoc(parsed, normalized, boundSigners)predicate (and optionally a small "fetch edges + boundSigners" helper) would keep the two paths from drifting apart as the binding model evolves.🤖 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 `@infrastructure/eid-wallet/src/lib/utils/socialBinding.ts` around lines 606 - 622, The stale-doc filtering logic in socialBinding.ts duplicates the same query and predicate flow used by fetchUnsignedSocialDocs, so refactor it to share a common helper. Extract a reusable isStaleBoundSignerDoc(parsed, normalized, boundSigners) predicate (and, if helpful, a small helper for fetching edges and computing boundSigners) that both pruneBoundSignerDocs and fetchUnsignedSocialDocs can call. Keep the current semantics intact: check parsed.type, parsed.subject, skip already-signed docs, and use the originator-in-boundSigners condition consistently so the two paths cannot drift.
🤖 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 `@infrastructure/eid-wallet/src/lib/utils/socialBinding.ts`:
- Around line 606-622: The stale-doc filtering logic in socialBinding.ts
duplicates the same query and predicate flow used by fetchUnsignedSocialDocs, so
refactor it to share a common helper. Extract a reusable
isStaleBoundSignerDoc(parsed, normalized, boundSigners) predicate (and, if
helpful, a small helper for fetching edges and computing boundSigners) that both
pruneBoundSignerDocs and fetchUnsignedSocialDocs can call. Keep the current
semantics intact: check parsed.type, parsed.subject, skip already-signed docs,
and use the originator-in-boundSigners condition consistently so the two paths
cannot drift.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: d095c624-c7ad-4c09-99ca-684810f3b7b2
⛔ Files ignored due to path filters (1)
infrastructure/eid-wallet/src-tauri/gen/android/.idea/deploymentTargetSelector.xmlis excluded by!**/gen/**
📒 Files selected for processing (2)
infrastructure/eid-wallet/src/lib/utils/socialBinding.tsinfrastructure/eid-wallet/src/routes/(app)/main/components/SocialBindingDrawer.svelte
… binded.
Description of change
Critical to know
The logic removes from backend the social bindings that came due to mistakenly re-scanning of qr even after binding was already done between the two parties. If we need to have an update by rescanning the qr, then the logic added in this PR needs to change.
Issue Number
Closes #1001
Type of change
How the change has been tested
Manually.
Change checklist
Summary by CodeRabbit