Skip to content

Commit

Permalink
Regression: Composer not reactive when omnichannel room closed (#26983)
Browse files Browse the repository at this point in the history
* Regression: Composer not reactive when omnichannel room closed

* Add TODO

Co-authored-by: Tasso Evangelista <tasso.evangelista@rocket.chat>
  • Loading branch information
MartinSchoeler and tassoevan committed Oct 3, 2022
1 parent 0e6bc45 commit 26941d5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const ComposerOmnichannel = (props: ComposerMessageProps): ReactElement =

const isSubscribed = useUserIsSubscribed();
const [isInquired, setIsInquired] = useState(() => !servedBy && queuedAt);
const [isOpen, setIsOpen] = useState(() => open);

const subscribeToRoom = useStream('room-data');

Expand All @@ -22,14 +23,15 @@ export const ComposerOmnichannel = (props: ComposerMessageProps): ReactElement =
useEffect(() => {
subscribeToRoom(_id, (entry: IOmnichannelRoom) => {
setIsInquired(!entry.servedBy && entry.queuedAt);
setIsOpen(entry.open);
});
}, [_id, subscribeToRoom]);

useEffect(() => {
setIsInquired(!servedBy && queuedAt);
}, [queuedAt, servedBy, _id]);

if (!open) {
if (!isOpen) {
return (
<footer className='rc-message-box footer'>
<MessageFooterCallout>{t('This_conversation_is_already_closed')}</MessageFooterCallout>
Expand Down
5 changes: 5 additions & 0 deletions apps/meteor/client/views/room/contexts/RoomContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ export const useRoomMessages = (): {
};

export const useOmnichannelRoom = (): IOmnichannelRoom => {
// TODO: today if the user do not belong in the room, the room object will not update on new changes
// for normal rooms this is OK, but for Omnichannel rooms,
// there are cases where an agent can be outside of the room but need to see the room changes
// A solution would be to use subscribeToRoom to get the room updates

const { room } = useContext(RoomContext) || {};

if (!room) {
Expand Down

0 comments on commit 26941d5

Please sign in to comment.