Skip to content

Commit

Permalink
Resolved Reviewed Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
henit-chobisa committed Jan 6, 2023
1 parent 638adc0 commit 45a018d
Showing 1 changed file with 12 additions and 11 deletions.
Expand Up @@ -4,29 +4,30 @@ import { useEndpoint, useTranslation } from '@rocket.chat/ui-contexts';
import type { ReactElement } from 'react';
import React, { useCallback, useRef, useEffect } from 'react';

import { dispatchToastMessage } from '../../../../../lib/toast';
import { useRoom, useUserIsSubscribed } from '../../../contexts/RoomContext';

export const ComposerReadOnly = (): ReactElement => {
const t = useTranslation();
const room = useRoom();
const isSubscribed = useUserIsSubscribed();
const calloutRef = useRef() as React.MutableRefObject<HTMLButtonElement>;
const joinEndpoint = useEndpoint('POST', '/v1/channels.join');
const joinChannel = useEndpoint('POST', '/v1/channels.join');

useEffect(() => {
if (!calloutRef.current) {
return;
}
calloutRef.current.style.flex = !isSubscribed ? '4' : 'none';
}, [isSubscribed]);

const join = useCallback(
async (_e) => {
try {
await joinEndpoint({ roomId: room._id });
} catch (error: any) {
console.log(error);
}
},
[joinEndpoint, room._id],
);
const join = useCallback(async () => {
try {
await joinChannel({ roomId: room._id });
} catch (error: unknown) {
dispatchToastMessage({ type: 'error', message: error });
}
}, [joinChannel, room._id]);

return (
<footer className='rc-message-box footer'>
Expand Down

0 comments on commit 45a018d

Please sign in to comment.