Skip to content

Commit 0da4c3b

Browse files
authored
Merge pull request #705 from GetStream/usePinHandler-docs
adds docs for usePinHandler
2 parents b0d30f5 + a99a39d commit 0da4c3b

File tree

8 files changed

+51
-5
lines changed

8 files changed

+51
-5
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# Changelog
22

3+
## [4.0.1](https://github.com/GetStream/stream-chat-react/releases/tag/v4.0.1) 2021-02-11
4+
5+
**NOTE: breaking changes in v4.0.0, this follow-up version patches the docs**
6+
7+
### Feature
8+
9+
- Add `usePinHandler` example to docs [#705](https://github.com/GetStream/stream-chat-react/pull/705)
10+
11+
### Bug
12+
13+
- Remove legacy APIs in mock data used for generating the docs [#704](https://github.com/GetStream/stream-chat-react/pull/704)
14+
315
## [4.0.0](https://github.com/GetStream/stream-chat-react/releases/tag/v4.0.0) 2021-02-10
416

517
### ⚠️ BREAKING CHANGES ⚠️

src/docs/useFlagHandler.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,4 @@ const MyCustomMessageComponent = (props) => {
2121
</div>
2222
);
2323
};
24-
`
2524
```

src/docs/useMuteHandler.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,4 @@ const MyCustomMessageComponent = (props) => {
2020
</div>
2121
);
2222
};
23-
`
2423
```

src/docs/useOpenThreadHandler.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,4 @@ const MyCustomMessageComponent = (props) => {
2222
</div>
2323
);
2424
};
25-
`
2625
```

src/docs/usePinHandler.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
A custom hook to handle message pinning. It provides the permission status of the connected user and a function to toggle pinned status on the message.
2+
3+
| Parameter | Type | Description |
4+
| ------------------------------------ | -------------------------------------------------------- | --------------------------------------------------------------- |
5+
| `message` | [object](https://getstream.io/chat/docs/#message_format) | The message to be handled. |
6+
| `permissions` | object | The user roles allowed to pin messages in various channel types |
7+
| `notifications` | object | An object containing the following properties: |
8+
| `notifications.notify` | func | A function that adds notification text to message |
9+
| `notifications.getErrorNotification` | func | A function that returns an error message |
10+
11+
It returns the following object:
12+
13+
| Parameter | Type | Description |
14+
| ----------- | ------- | -------------------------------------------------- |
15+
| `canPin` | boolean | Whether or not the connected user can pin messages |
16+
| `handlePin` | func | Function to toggle the pinned status of a message |
17+
18+
```json
19+
import { usePinHandler } from 'stream-chat-react';
20+
const MyCustomMessageComponent = (props) => {
21+
const { addNotification, getPinMessageErrorNotification, message, pinPermissions } = props;
22+
const { canPin, handlePin } = usePinHandler(message, pinPermissions, {
23+
notify: addNotification,
24+
getErrorNotification: getPinMessageErrorNotification,
25+
});
26+
const handleClick = () => {
27+
if (canPin) handlePin(message);
28+
}
29+
return (
30+
<div className={message.pinned ? 'pinned' : ''} onClick={handleClick}>
31+
<p>{message.text}</p>
32+
</div>
33+
);
34+
};
35+
```

src/docs/useReactionHandler.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,4 @@ const MyCustomMessageComponent = (props) => {
2222
</div>
2323
);
2424
};
25-
`
2625
```

src/docs/useRetryHandler.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,4 @@ const MyCustomMessageComponent = (props) => {
2929
</div>
3030
);
3131
};
32-
`
3332
```

styleguide.config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ module.exports = {
8181
name: 'useOpenThreadHandler',
8282
content: 'src/docs/useOpenThreadHandler.md',
8383
},
84+
{
85+
name: 'usePinHandler',
86+
content: 'src/docs/usePinHandler.md',
87+
},
8488
{
8589
name: 'useReactionHandler',
8690
content: 'src/docs/useReactionHandler.md',

0 commit comments

Comments
 (0)