Skip to content
This repository was archived by the owner on Nov 13, 2024. It is now read-only.

Commit 45f1c79

Browse files
committed
Add info on APIs to hooks & add missing VSP fields to spec
1 parent 7624cfb commit 45f1c79

File tree

4 files changed

+45
-12
lines changed

4 files changed

+45
-12
lines changed

lib/docs/stories/hooks/use-channel-members.stories.mdx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,18 @@ import { Meta } from "@storybook/addon-docs/blocks";
44

55
# `useChannelMembers`
66

7-
The hook returns a list of members in a channel.
7+
The hook uses the [Metadata API](https://www.pubnub.com/docs/sdks/javascript/api-reference/objects#get-channel-memberships) for channel members.
8+
9+
It returns a list of members in a given channel.
810

911
The list will include user metadata for members that have additional metadata stored in the
1012
database. Pagination is handled internally. You can adjust the `limit` of returned members on a
1113
single call (max/default 100) and call a function returned by the hook to get another page of
1214
results.
1315

14-
This hook also sets up a listener that reacts to removals of already fetched members. Updates and
16+
This hook also sets up a listener that reacts to removals of the already-fetched members. Updates and
1517
new memberships are not handled due to technical limitations. However, this behavior requires a
16-
living subscription to the channel getting updated - this should be handled by the components.
18+
living subscription for the channel to get updated - this should be handled by the components.
1719

1820
```js
1921
const [members, fetchPage, refetchChannelMembers, total, error] = useChannelMembers({

lib/docs/stories/hooks/use-memberships.stories.mdx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,18 @@ import { Meta } from "@storybook/addon-docs/blocks";
44

55
# `useMemberships`
66

7-
Depending on the input arguments, the hook returns a list of members in a channel, or a list of
7+
This hook uses the new [Memberships API](https://www.pubnub.com/docs/sdks/javascript/api-reference/memberships).
8+
9+
Depending on the input arguments, the hook returns a list of members in a channel or a list of
810
channels a given user is a member of.
911

1012
The list will include metadata for memberships that have additional metadata stored in the database.
1113
Pagination is handled internally. You can adjust the `limit` of returned memberships on a single
1214
call (max/default 100) and call a function returned by the hook to get another page of results.
1315

14-
This hook also sets up a listener that reacts to removals of already fetched memberships. Updates
16+
This hook also sets up a listener that reacts to removals of the already-fetched memberships. Updates
1517
and new memberships are not handled due to technical limitations. However, this behavior requires a
16-
living subscription to the channel getting updated - this should be handled by the components.
18+
living subscription for the channel to get updated - this should be handled by the components.
1719

1820
```js
1921
const [users, fetchPage, refetchMemberships, total, error] = useMemberships({
@@ -61,6 +63,6 @@ return (
6163
| :---------- | :---------------------------- | --------------------------------------------------------------------------------------------------------------- |
6264
| `array[0]` | UserEntity[] or SpaceEntity[] | List of returned memberships. |
6365
| `array[1] ` | Function | Function that can be called to fetch another page of members. |
64-
| `array[2]` | Function | Function that can be called to completely reset the hook. This can be used in case of expected members updates. |
66+
| `array[2]` | Function | Function that can be called to completely reset the hook. This can be used in case of expected updates of members. |
6567
| `array[3]` | Number | Total number of stored members. |
6668
| `array[4]` | Error | If there's an error fetching members, it will be available here. |

lib/docs/stories/hooks/use-user-memberships.stories.mdx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,17 @@ import { Meta } from "@storybook/addon-docs/blocks";
44

55
# `useUserMemberships`
66

7-
The hook returns a list of channel memberships for a user.
7+
The hook uses the [Metadata API](https://www.pubnub.com/docs/sdks/javascript/api-reference/objects#get-channel-members) for user memberships.
8+
9+
It returns a list of channel memberships for a given user.
810

911
This method doesn't return user's subscriptions. Pagination is handled internally. You can adjust
10-
the `limit` of returned channes on a single call (max/default `100`) and call a function returned by
12+
the `limit` of returned channels on a single call (max/default `100`) and call a function returned by
1113
the hook to get another page of results.
1214

13-
This hook also sets up a listener that reacts to removals of already fetched channels. Updates and
15+
This hook also sets up a listener that reacts to removals of the already-fetched channels. Updates and
1416
new memberships are not handled due to technical limitations. However, this behavior requires a
15-
living subscription to the user getting updated - this should be handled by the components.
17+
living subscription for the user to get updated - this should be handled by the components.
1618

1719
```js
1820
const [channels, fetchPage, refetchMemberships, total, error] = useUserMemberships({

lib/docs/stories/introduction/payloads.stories.mdx

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,17 @@ Follow this schema for the user data in your apps:
4444
"description": "URL to a user avatar that you can display in the UI",
4545
"type": "string"
4646
},
47+
"type": {
48+
"description": "Type of the user",
49+
"type": "string",
50+
"examples": ["default", "admin", "moderator"],
51+
"default": "default"
52+
},
53+
"status": {
54+
"description": "Status of the user",
55+
"type": "string",
56+
"examples": ["default", "deleted"]
57+
},
4758
"custom": {
4859
"description": "Any additional payload information",
4960
"type": "object",
@@ -63,7 +74,7 @@ Follow this schema for the user data in your apps:
6374
"type": "string"
6475
}
6576
},
66-
"required": ["id"]
77+
"required": ["id", "type"]
6778
}
6879
```
6980

@@ -76,6 +87,8 @@ Example:
7687
"email": "[email protected]",
7788
"externalId": "some-external-user-id",
7889
"profileUrl": "https://randomuser.me/api/portraits/men/1.jpg",
90+
"type": "default",
91+
"status": "default",
7992
"custom": {
8093
"description": "Office Assistant"
8194
},
@@ -93,6 +106,7 @@ Follow this schema for the channel data in your apps:
93106
"$schema": "https://json-schema.org/draft/2020-12/schema",
94107
"title": "Channel",
95108
"description": "Channel in the chat application",
109+
"type": "object",
96110
"properties": {
97111
"id": {
98112
"description": "Unique identifier for a channel",
@@ -106,6 +120,17 @@ Follow this schema for the channel data in your apps:
106120
"description": "Description of the channel that you can display in the UI",
107121
"type": "string"
108122
},
123+
"type": {
124+
"description": "Type of the channel",
125+
"type": "string",
126+
"examples": ["default", "group", "direct"],
127+
"default": "default"
128+
},
129+
"status": {
130+
"description": "Status of the channel",
131+
"type": "string",
132+
"examples": ["default", "deleted"]
133+
},
109134
"custom": {
110135
"description": "Any additional payload information",
111136
"type": "object",
@@ -136,6 +161,8 @@ Example:
136161
"id": "some-channel-id",
137162
"name": "Off-topic",
138163
"description": "Off-topic channel for random chatter and fun",
164+
"type": "default",
165+
"status": "default",
139166
"custom": {
140167
"profileUrl": "https://www.gravatar.com/avatar/149e60f311749f2a7c6515f7b34?s=256&d=identicon"
141168
},

0 commit comments

Comments
 (0)