Skip to content

Commit

Permalink
refactor: renamed useRoomCloseAction to useHideRoomAction
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksandernsilva committed Nov 21, 2024
1 parent 8637ced commit fa7206d
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ import { useMutation } from '@tanstack/react-query';
import React from 'react';
import { useTranslation } from 'react-i18next';

import { useDontAskAgain } from './useDontAskAgain';
import { UiTextContext } from '../../definition/IRoomTypeConfig';
import { GenericModalDoNotAskAgain } from '../components/GenericModal';
import { roomCoordinator } from '../lib/rooms/roomCoordinator';
import { useDontAskAgain } from './useDontAskAgain';

type RoomCloseProps = {
type HideRoomProps = {
rid: string;
type: RoomType;
name: string;
};

type RoomCloseOptions = {
type HideRoomOptions = {
redirect?: boolean;
};

Expand All @@ -29,7 +29,7 @@ const CLOSE_ENDPOINTS_BY_ROOM_TYPE = {
l: '/v1/groups.close', // livechat
} as const;

export const useRoomCloseAction = ({ rid, type, name }: RoomCloseProps, { redirect = true }: RoomCloseOptions = {}) => {
export const useHideRoomAction = ({ rid, type, name }: HideRoomProps, { redirect = true }: HideRoomOptions = {}) => {
const { t } = useTranslation();
const setModal = useSetModal();
const closeModal = useEffectEvent(() => setModal());
Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/client/sidebar/RoomMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import React, { memo, useMemo } from 'react';
import { LegacyRoomManager } from '../../app/ui-utils/client';
import { UiTextContext } from '../../definition/IRoomTypeConfig';
import WarningModal from '../components/WarningModal';
import { useRoomCloseAction } from '../hooks/useRoomCloseAction';
import { useHideRoomAction } from '../hooks/useHideRoomAction';
import { roomCoordinator } from '../lib/rooms/roomCoordinator';
import { useOmnichannelPrioritiesMenu } from '../omnichannel/hooks/useOmnichannelPrioritiesMenu';

Expand Down Expand Up @@ -90,7 +90,7 @@ const RoomMenu = ({

const queryClient = useQueryClient();

const handleHide = useRoomCloseAction({ rid, type, name }, { redirect: false });
const handleHide = useHideRoomAction({ rid, type, name }, { redirect: false });

const canLeave = ((): boolean => {
if (type === 'c' && !canLeaveChannel) {
Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/client/sidebarv2/RoomMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import React, { memo, useMemo } from 'react';
import { LegacyRoomManager } from '../../app/ui-utils/client';
import { UiTextContext } from '../../definition/IRoomTypeConfig';
import WarningModal from '../components/WarningModal';
import { useRoomCloseAction } from '../hooks/useRoomCloseAction';
import { useHideRoomAction } from '../hooks/useHideRoomAction';
import { roomCoordinator } from '../lib/rooms/roomCoordinator';
import { useOmnichannelPrioritiesMenu } from '../omnichannel/hooks/useOmnichannelPrioritiesMenu';

Expand Down Expand Up @@ -90,7 +90,7 @@ const RoomMenu = ({

const queryClient = useQueryClient();

const handleHide = useRoomCloseAction({ rid, type, name }, { redirect: false });
const handleHide = useHideRoomAction({ rid, type, name }, { redirect: false });

const canLeave = ((): boolean => {
if (type === 'c' && !canLeaveChannel) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import type { IRoom } from '@rocket.chat/core-typings';
import { useMemo } from 'react';
import { useTranslation } from 'react-i18next';

import { useRoomCloseAction } from '../../../../../hooks/useRoomCloseAction';
import { useDeleteRoom } from '../../../../hooks/roomActions/useDeleteRoom';
import { useRoomConvertToTeam } from './actions/useRoomConvertToTeam';
import { useRoomLeave } from './actions/useRoomLeave';
import { useRoomMoveToTeam } from './actions/useRoomMoveToTeam';
import { useHideRoomAction } from '../../../../../hooks/useHideRoomAction';
import { useDeleteRoom } from '../../../../hooks/roomActions/useDeleteRoom';

type UseRoomActionsOptions = {
onClickEnterRoom?: () => void;
Expand All @@ -23,7 +23,7 @@ export const useRoomActions = (room: IRoom, options: UseRoomActionsOptions) => {
const { handleDelete, canDeleteRoom } = useDeleteRoom(room, { reload: resetState });
const handleMoveToTeam = useRoomMoveToTeam(room);
const handleConvertToTeam = useRoomConvertToTeam(room);
const handleHide = useRoomCloseAction({ rid: room._id, type: room.t, name: room.name ?? '' });
const handleHide = useHideRoomAction({ rid: room._id, type: room.t, name: room.name ?? '' });

return useMemo(() => {
const memoizedActions = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import { useSetModal, useToastMessageDispatch, useUserId, usePermission, useRout
import React, { useCallback } from 'react';
import { useTranslation } from 'react-i18next';

import LeaveTeam from './LeaveTeam';
import TeamsInfo from './TeamsInfo';
import { useEndpointAction } from '../../../../hooks/useEndpointAction';
import { useRoomCloseAction } from '../../../../hooks/useRoomCloseAction';
import { useHideRoomAction } from '../../../../hooks/useHideRoomAction';
import { useDeleteRoom } from '../../../hooks/roomActions/useDeleteRoom';
import { useRoom } from '../../../room/contexts/RoomContext';
import { useRoomToolbox } from '../../../room/contexts/RoomToolboxContext';
import ConvertToChannelModal from '../../ConvertToChannelModal';
import LeaveTeam from './LeaveTeam';
import TeamsInfo from './TeamsInfo';

type TeamsInfoWithLogicProps = {
openEditing: () => void;
Expand All @@ -30,7 +30,7 @@ const TeamsInfoWithLogic = ({ openEditing }: TeamsInfoWithLogicProps) => {
const leaveTeam = useEndpointAction('POST', '/v1/teams.leave');
const convertTeamToChannel = useEndpointAction('POST', '/v1/teams.convertToChannel');

const hideTeam = useRoomCloseAction({ rid: room._id, type: room.t, name: room.name ?? '' });
const hideTeam = useHideRoomAction({ rid: room._id, type: room.t, name: room.name ?? '' });

const router = useRouter();

Expand Down

0 comments on commit fa7206d

Please sign in to comment.