Skip to content

feat(notifications): add deterministic notification preference handling (#885) - #931

Draft
s6pa1rta3n-lab wants to merge 1 commit into
Predictify-org:mainfrom
s6pa1rta3n-lab:fix-issue
Draft

feat(notifications): add deterministic notification preference handling (#885)#931
s6pa1rta3n-lab wants to merge 1 commit into
Predictify-org:mainfrom
s6pa1rta3n-lab:fix-issue

Conversation

@s6pa1rta3n-lab

Copy link
Copy Markdown

Closes #885

Summary

Implements deterministic notification preference handling with strict account isolation, explicit defaults, offline mutation queueing, and conflict reconciliation.

Acceptance Criteria

  • Preferences are isolated by account: Preference states are mapped by normalized account address (account: string), preventing cross-contamination when users switch wallets.
  • Defaults are explicit: Frozen default values define all categories (settlement, market, wallet, dispute, payout, system, account) and delivery channels (inApp, email, push).
  • Offline changes reconcile without duplication: Offline mutations are queued idempotently and reconciled with remote/server states using deterministic Last-Write-Wins (LWW) timestamp logic.
  • Tests cover account switch, conflict, and reset: Comprehensive unit tests cover account switching, conflict resolution, offline queue deduplication, and defaults reset.

Architecture & Implementation

  • Type Definitions (types/notification-preferences.ts): Granular types for category toggles, channel toggles, intensity presets, offline mutation records, and reconciliation payloads.
  • Preferences Engine (lib/notification-preferences.ts): Immutable explicit defaults, account normalization, defensive deserialization, offline mutation applying, deterministic reconciliation (reconcilePreferences), and decision evaluation (shouldDeliverNotification).
  • Scoped Store (app/state/notificationPreferences.ts): Zustand store with persist middleware, cross-tab synchronization via storage event listener, and online/offline event listeners.
  • React Hook (hooks/useNotificationPreferences.ts): Auto-synchronizes with WalletContext address changes and exposes helper methods to components.
  • Settings UI (app/(dashboard)/settings/page.tsx): Updated settings page to display account-scoped notification preferences, category/channel controls, intensity presets, and one-click "Reset to defaults".

Security and Failure-Mode Considerations

  • Account Isolation: Preference lookup strictly normalizes and keys on account identifier, ensuring no leakage of preferences across multiple wallets.
  • Defensive Parsing & Fallbacks: Malformed or corrupt storage payloads are caught and populated with valid explicit defaults without throwing runtime exceptions.
  • Offline Idempotency: Offline mutations use unique deterministic IDs to prevent duplicate queue items or replay loops.
  • Quiet Hours & Critical Alert Bypass: Critical alerts (e.g. disputes, transaction failures) bypass quiet hours suppression to ensure user fund safety.

Verification & Tests

  • lib/__tests__/notification-preferences.test.ts: 100% passing tests for normalization, defaults, offline queueing, conflict resolution, and filtering.
  • app/state/__tests__/notificationPreferences.test.ts: 100% passing tests for account switching, explicit defaults, reset, offline queueing, and persistence.
  • hooks/__tests__/useNotificationPreferences.test.tsx: 100% passing tests for React hook integration and dynamic wallet account switching.

Payout Routing

  • EVM (Base/Arbitrum/Polygon/ETH): 0xF46C9F6d70C50BF81ef3588AB523a90a594a2F89
  • Stellar: GCL6OXAMLD75BMTINA6EMRUDWK5THQUSHMYNLSNBCJAPZJHNYJTUNIBC

@vercel

vercel Bot commented Aug 29, 2026

Copy link
Copy Markdown

@s6pa1rta3n-lab is attempting to deploy a commit to the Jagadeesh B's projects Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[GrantFox][Medium] Add deterministic notification preference handling

1 participant