File tree Expand file tree Collapse file tree 3 files changed +20
-0
lines changed Expand file tree Collapse file tree 3 files changed +20
-0
lines changed Original file line number Diff line number Diff line change 11# Changelog
22
3+ ## [ 3.3.1] ( https://github.com/GetStream/stream-chat-react/releases/tag/v3.3.1 ) 2020-12-9
4+
5+ ## Fix
6+
7+ - Add additional user role check for ` isModerator ` boolean [ #625 ] ( https://github.com/GetStream/stream-chat-react/pull/625 )
8+
39## [ 3.3.0] ( https://github.com/GetStream/stream-chat-react/releases/tag/v3.3.0 ) 2020-12-3
410
511## Feature
Original file line number Diff line number Diff line change @@ -513,6 +513,19 @@ describe('<Message /> component', () => {
513513 expect ( getMessageActions ( ) ) . toContain ( MESSAGE_ACTIONS . delete ) ;
514514 } ) ;
515515
516+ it ( 'should allow user to edit and delete message when moderator role is set on client' , async ( ) => {
517+ const amin = generateUser ( {
518+ name : 'amin' ,
519+ role : 'channel_moderator' ,
520+ } ) ;
521+ const client = await getTestClientWithUser ( amin ) ;
522+ const message = generateMessage ( { user : bob } ) ;
523+ await renderComponent ( message , { } , { client } ) ;
524+ const { getMessageActions } = getRenderedProps ( ) ;
525+ expect ( getMessageActions ( ) ) . toContain ( MESSAGE_ACTIONS . edit ) ;
526+ expect ( getMessageActions ( ) ) . toContain ( MESSAGE_ACTIONS . delete ) ;
527+ } ) ;
528+
516529 it ( 'should allow user to edit and delete message when user is admin' , async ( ) => {
517530 const message = generateMessage ( { user : bob } ) ;
518531 await renderComponent (
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ export const useUserRole = (message) => {
1616 channel ?. state ?. membership ?. role === 'admin' ;
1717 const isOwner = channel ?. state ?. membership ?. role === 'owner' ;
1818 const isModerator =
19+ client ?. user ?. role === 'channel_moderator' ||
1920 channel ?. state ?. membership ?. role === 'channel_moderator' ||
2021 channel ?. state ?. membership ?. role === 'moderator' ;
2122 const canEditMessage = isMyMessage || isModerator || isOwner || isAdmin ;
You can’t perform that action at this time.
0 commit comments