@poolse/react 2.0.5 → 2.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +8 -13
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -85,27 +85,22 @@ Fetches `GET /v1/me` once on mount. Identity is stable for the JWT's lifetime, s
85
85
 
86
86
  ### `useConversation(id): { conversation, loading, error, refetch }`
87
87
 
88
- Single conversation, REST-only. The server doesn't broadcast `conversation:updated` today, so changes (name, settings) won't show up live — call `refetch()` after a mutation. Pass `null` to skip the fetch.
88
+ Single conversation, REST-only. Settings changes (name, avatar) won't show up live on this hook — call `refetch()` after a mutation. Live message activity for the same conversation flows through `useMessages` instead. Pass `null` to skip the fetch.
89
89
 
90
90
  ### `useConversations(): { conversations, create, unreadCounts, markConversationRead, ... }`
91
91
 
92
- The user's conversation list. On mount: fetches `GET /v1/conversations` and subscribes to the user's own `user:<id>` channel for `conversation:created` events (fires both when this user creates a conversation and when someone else adds them to one). `unreadCounts` is populated from `Conversation.unread_count` on the initial fetch.
92
+ The user's conversation list. On mount it fetches `GET /v1/conversations` and subscribes to the user's own `user:<id>` channel for two events: `conversation:created` (fires both when this user creates a conversation and when someone else adds them to one) and `conversation:updated` (fires after every message sent in any of their conversations).
93
+
94
+ Return shape:
93
95
 
94
96
  ```ts
95
- const {
96
- conversations, // Conversation[]
97
- loading,
98
- error,
99
- refetch, // () => Promise<void>
100
- create, // (attrs: ConversationCreateRequest) => Promise<Conversation>
101
- unreadCounts, // Record<Uuid, number>
102
- markConversationRead, // (conversationId: Uuid) => void — zeroes the badge locally
103
- } = useConversations();
97
+ const { conversations, loading, error, refetch, create, unreadCounts, markConversationRead } =
98
+ useConversations();
104
99
  ```
105
100
 
106
- `create()` optimistically prepends the conversation to local state. When the realtime echo arrives with the same id, an id-based dedup replaces the row in place — no double-insert.
101
+ `conversations` is the list of `Conversation` rows. `refetch()` does an explicit re-sync. `create(attrs)` calls `POST /v1/conversations` and optimistically prepends the result; when the realtime echo arrives with the same id, id-based dedup replaces the row in place so there's no double-insert.
107
102
 
108
- Unread counts only stay correct for the conversation the user is actually viewing (`useMessages` advances the read cursor) plus whatever was fresh at fetch time. The hook doesn't subscribe to every conversation in the list — that would mean N channels just to keep N sidebar badges live. Refetch on tab focus or accept the drift.
103
+ `unreadCounts` is `Record<Uuid, number>`. Initial values come from the server's `Conversation.unread_count`. The `conversation:updated` subscription keeps them live without polling: when another member sends a message, the corresponding row's preview, timestamp, and unread badge update in place; when YOU send (`by_user_id` equals your id) the row floats to the top and unread stays at 0 (the server already advanced your read cursor in the same transaction). `markConversationRead(conversationId)` zeroes the badge locally — wire this from `ConversationView.onMarkedRead` so the sidebar clears immediately, before the server's read-receipt echo round-trips.
109
104
 
110
105
  ### `useMessages(conversationId): { messages, send, edit, delete, loadMore, hasMore, markReadUpTo, ... }`
111
106
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@poolse/react",
3
- "version": "2.0.5",
3
+ "version": "2.0.7",
4
4
  "description": "Headless React hooks for poolse — realtime chat infrastructure. Provider + useMessages / useTyping / usePresence / useReactions / useAttachmentUpload / etc. NO UI.",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -43,7 +43,7 @@
43
43
  "CHANGELOG.md"
44
44
  ],
45
45
  "dependencies": {
46
- "@poolse/sdk": "2.0.5"
46
+ "@poolse/sdk": "2.0.7"
47
47
  },
48
48
  "peerDependencies": {
49
49
  "react": ">=18"