@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.
- package/README.md +8 -13
- 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.
|
|
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
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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.
|
|
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.
|
|
46
|
+
"@poolse/sdk": "2.0.7"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
49
|
"react": ">=18"
|