-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Add
roomName
on Composer placeholder (#29255)
Co-authored-by: Guilherme Gazzo <guilhermegazzo@gmail.com>
- Loading branch information
1 parent
bbc21e9
commit e116d88
Showing
7 changed files
with
60 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@rocket.chat/meteor": minor | ||
--- | ||
|
||
chore: Add `roomName` on Composer placeholder |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import type { IRoom } from '@rocket.chat/core-typings'; | ||
import { isDirectMessageRoom } from '@rocket.chat/core-typings'; | ||
import { useUserSubscription } from '@rocket.chat/ui-contexts'; | ||
|
||
import { useUserDisplayName } from './useUserDisplayName'; | ||
|
||
/** | ||
* | ||
* Hook to get the name of the room | ||
* | ||
* @param room - Room object | ||
* @returns Room name | ||
* @public | ||
* | ||
*/ | ||
export const useRoomName = (room: IRoom) => { | ||
const subscription = useUserSubscription(room._id); | ||
const username = useUserDisplayName({ name: subscription?.fname, username: subscription?.name }); | ||
|
||
if (isDirectMessageRoom(room)) { | ||
return username; | ||
} | ||
|
||
return room.fname || room.name; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...r/client/views/room/components/body/composer/messageBox/hooks/useMessageBoxPlaceholder.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import type { IRoom } from '@rocket.chat/core-typings'; | ||
import { isDirectMessageRoom } from '@rocket.chat/core-typings'; | ||
|
||
import { useRoomName } from '../../../../../../../hooks/useRoomName'; | ||
|
||
export const useMessageBoxPlaceholder = (placeholder: string, room?: IRoom) => { | ||
if (!room) { | ||
throw new Error('In order to get the placeholder a `room` must be provided'); | ||
} | ||
|
||
const roomName = useRoomName(room); | ||
|
||
if (isDirectMessageRoom(room)) { | ||
return `${placeholder} @${roomName}`; | ||
} | ||
|
||
return `${placeholder} #${roomName}`; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters