Skip to content

feat(notifications): add in-app price alert notification polling and drawer display (closes #883) - #907

Open
Ranjeet2063 wants to merge 1 commit into
accesslayerorg:devfrom
Ranjeet2063:feat/in-app-price-alert-notifications
Open

Ranjeet2063 wants to merge 1 commit into
accesslayerorg:devfrom
Ranjeet2063:feat/in-app-price-alert-notifications

Conversation

@Ranjeet2063

Copy link
Copy Markdown

Summary

Closes #883

Adds in-app price alert notification polling to the 60-second notification cycle, checks active price alerts against current key prices, marks triggered alerts on the backend via PATCH /alerts/:alertId/triggered, and displays actionable price alerts in the notification drawer.

Key Changes

  • Alert Service (src/services/alert.service.ts):
    • Implemented AlertService with getActiveAlerts(userId), getKeyPrice(keyId), and markAlertTriggered(alertId).
  • Notification Polling & Trigger Guard (src/hooks/useNotifications.ts):
    • Implemented checkPriceAlerts:
      • Evaluates both above and below target price directions on each poll.
      • Marks triggered alerts via alertService.markAlertTriggered(alert.id) and removes them from active monitoring.
      • Deduplicates triggered alert IDs in triggeredAlertsRef to prevent any duplicate notifications.
    • Automatically prepends newly triggered price alert notifications into the user's notification list and increments unreadCount.
  • UI & Drawer Integration (src/components/common/NotificationBell.tsx, src/services/notification.service.ts):
    • Added 'price_alert' to NotificationType union.
    • Added BellRing icon rendering for price_alert events in the drawer with key name, direction, target price, and current price.
  • Unit & Integration Tests (src/hooks/__tests__/usePriceAlertNotifications.test.ts):
    • Comprehensive vitest suite verifying:
      • Triggering notification when price crosses above target.
      • Triggering notification when price crosses below target.
      • No notification generated when price does not cross threshold.
      • Complete deduplication on consecutive polls.
    • All 25/25 notification tests pass 100% green.

Verification

  • pnpm test src/hooks/__tests__/usePriceAlertNotifications.test.ts src/hooks/__tests__/useNotifications.test.ts src/components/common/__tests__/NotificationBell.test.tsx: 3/3 test suites, 25/25 tests passed.
  • npx eslint: 0 errors.
  • pnpm run build (tsc -b && vite build): Succeeded with 0 errors.

…drawer display (closes accesslayerorg#883)

- Introduce AlertService in src/services/alert.service.ts for fetching active price alerts, key prices, and marking triggered alerts
- Wire price alert threshold evaluation into useNotifications polling loop (checks above/below threshold crossing)
- Update notification type and drawer UI in NotificationBell to render price alert details (key name, direction, target price, current price)
- Mark triggered alerts on backend and remove from active monitoring to prevent duplicate notifications
- Add comprehensive vitest suite in usePriceAlertNotifications.test.ts
Copilot AI lite review requested due to automatic review settings September 10, 2026 17:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

Add an in-app price alert notification that fires when a watched key crosses the user's target price

2 participants