Skip to content

Migrate notifications to skatehive-api /api/v2/notifications endpoint #17

Description

@rferrari

Context

The API is getting a dedicated, edge-cached notifications endpoint:
SkateHive/skatehive-api#36GET /api/v2/notifications/[username].

It was modeled on this app's implementation (the gold standard): it returns each notification with an isRead flag (matching our HiveNotification shape), plus lastRead and an unread count, and derives read status with the same recursive last-read scan (findLastNotificationsReset logic, up to 5×1000 history ops). It supports limit (max 100) and last_id pagination.

Response:

{
  "success": true,
  "data": {
    "notifications": [{ "id": 1, "type": "reply", "score": 40, "date": "...", "msg": "...", "url": "...", "isRead": false }],
    "lastRead": "2026-07-03T03:00:00",
    "unread": 2
  }
}

Task (do this once skatehive-api#36 lands)

Switch notification reads from direct Hive RPC to the API, consistent with how lib/api.ts already consumes feed/profile/balance:

  • Add a getNotifications(username, { limit, lastId }) wrapper in lib/api.ts (reuse fetchWithRetry).
  • Point lib/hooks/useNotifications.ts / lib/notifications-context.tsx at the API wrapper instead of fetchAllNotifications / fetchNewNotifications in lib/hive-utils.ts.
  • Map the { success, data: { notifications, lastRead, unread } } envelope to the existing HiveNotification[] shape (the isRead flag is already provided).
  • Keep a direct-RPC fallback if the endpoint is unavailable (same pattern as getVideoFeed), then deprecate the RPC helpers in hive-utils.ts once stable.

Out of scope

Mark-as-read stays a client-signed broadcast (write) — the API endpoint is read-only. No change to signing.

Blocked by

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions