Skip to content

Commit

Permalink
refactor: Correct call of setModal (#34871)
Browse files Browse the repository at this point in the history
  • Loading branch information
tassoevan authored Jan 3, 2025
1 parent c5f23ab commit 6ec661b
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion apps/meteor/client/apps/gameCenter/GameCenterList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const GameCenterList = ({ handleClose, handleOpenGame, games, isLoading }: IGame
const handleClose = (): void => {
setModal(null);
};
setModal(() => <GameCenterInvitePlayersModal onClose={handleClose} game={game} />);
setModal(<GameCenterInvitePlayersModal onClose={handleClose} game={game} />);
},
[setModal],
);
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/client/providers/CallProvider/CallProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export const CallProvider = ({ children }: CallProviderProps) => {
);

const openWrapUpModal = useCallback((): void => {
setModal(() => <WrapUpCallModal closeRoom={closeRoom} />);
setModal(<WrapUpCallModal closeRoom={closeRoom} />);
}, [closeRoom, setModal]);

const changeAudioOutputDevice = useMutableCallback((selectedAudioDevice: Device): void => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ export const useCreateRoomModal = (Component: ElementType<{ onClose: () => void
setModal(null);
};

setModal(() => <Component onClose={handleClose} />);
setModal(<Component onClose={handleClose} />);
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ export const useCreateRoomModal = (Component: FC<any>): (() => void) => {
setModal(null);
};

setModal(() => <Component onClose={handleClose} />);
setModal(<Component onClose={handleClose} />);
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,16 @@ const AccountProfilePage = (): ReactElement => {
}
};

return setModal(() => (
return setModal(
<ConfirmOwnerChangeModal
onConfirm={handleConfirm}
onCancel={() => setModal(null)}
contentTitle={t(`Delete_User_Warning_${erasureType}` as TranslationKey)}
confirmText={t('Delete')}
shouldChangeOwner={shouldChangeOwner}
shouldBeRemoved={shouldBeRemoved}
/>
));
/>,
);
},
[erasureType, setModal, t, deleteOwnAccount, dispatchToastMessage, logout],
);
Expand All @@ -106,7 +106,7 @@ const AccountProfilePage = (): ReactElement => {
}
};

return setModal(() => <ActionConfirmModal onConfirm={handleConfirm} onCancel={() => setModal(null)} isPassword={hasLocalPassword} />);
return setModal(<ActionConfirmModal onConfirm={handleConfirm} onCancel={() => setModal(null)} isPassword={hasLocalPassword} />);
}, [dispatchToastMessage, hasLocalPassword, setModal, handleConfirmOwnerChange, deleteOwnAccount, logout, t]);

const profileFormId = useUniqueId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,11 @@ const EditCustomEmoji = ({ close, onChange, data, ...props }: EditCustomEmojiPro
setModal(null);
};

setModal(() => (
setModal(
<GenericModal variant='danger' onConfirm={handleDelete} onCancel={handleCancel} onClose={handleCancel} confirmText={t('Delete')}>
{t('Custom_Emoji_Delete_Warning')}
</GenericModal>
));
</GenericModal>,
);
}, [setModal, deleteAction, _id, dispatchToastMessage, t, onChange, close]);

const handleChangeAliases = useCallback(
Expand Down
6 changes: 3 additions & 3 deletions apps/meteor/client/views/admin/customSounds/EditSound.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,11 @@ function EditSound({ close, onChange, data, ...props }: EditSoundProps): ReactEl

const handleCancel = (): void => setModal(null);

setModal(() => (
setModal(
<GenericModal variant='danger' onConfirm={handleDelete} onCancel={handleCancel} onClose={handleCancel} confirmText={t('Delete')}>
{t('Custom_Sound_Delete_Warning')}
</GenericModal>
));
</GenericModal>,
);
}, [_id, close, deleteCustomSound, dispatchToastMessage, onChange, setModal, t]);

const [clickUpload] = useSingleFileInput(handleChangeFile, 'audio/mp3');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ const CustomUserStatusForm = ({ onClose, onReload, status }: CustomUserStatusFor
}
};

setModal(() => (
setModal(
<GenericModal variant='danger' onConfirm={handleDelete} onCancel={handleCancel} onClose={handleCancel} confirmText={t('Delete')}>
{t('Custom_User_Status_Delete_Warning')}
</GenericModal>
));
</GenericModal>,
);
}, [_id, route, deleteStatus, dispatchToastMessage, onReload, setModal, t]);

const presenceOptions: SelectOption[] = [
Expand Down
6 changes: 3 additions & 3 deletions apps/meteor/client/views/admin/oauthApps/EditOauthApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const EditOauthApp = ({ onChange, data, ...props }: EditOauthAppProps): ReactEle
}, [data._id, close, deleteApp, dispatchToastMessage, setModal, t]);

const openConfirmDelete = (): void =>
setModal(() => (
setModal(
<GenericModal
variant='danger'
onConfirm={onDeleteConfirm}
Expand All @@ -96,8 +96,8 @@ const EditOauthApp = ({ onChange, data, ...props }: EditOauthAppProps): ReactEle
confirmText={t('Delete')}
>
{t('Application_delete_warning')}
</GenericModal>
));
</GenericModal>,
);

return (
<ContextualbarScrollableContent w='full' {...props}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export const useChangeModeratorAction = (user: Pick<IUser, '_id' | 'username'>,

const changingOwnRole = userId === loggedUserId;
if (changingOwnRole && loggedUserIsModerator) {
return setModal(() =>
return setModal(
getWarningModalForFederatedRooms(
closeModal,
handleConfirm,
Expand All @@ -119,7 +119,7 @@ export const useChangeModeratorAction = (user: Pick<IUser, '_id' | 'username'>,
}

if (changingOwnRole && loggedUserIsOwner) {
return setModal(() =>
return setModal(
getWarningModalForFederatedRooms(
closeModal,
handleConfirm,
Expand All @@ -131,7 +131,7 @@ export const useChangeModeratorAction = (user: Pick<IUser, '_id' | 'username'>,
}

if (!changingOwnRole && loggedUserIsModerator) {
return setModal(() =>
return setModal(
getWarningModalForFederatedRooms(
closeModal,
handleConfirm,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export const useChangeOwnerAction = (user: Pick<IUser, '_id' | 'username'>, rid:
};

if (changingOwnRole && loggedUserIsOwner) {
return setModal(() =>
return setModal(
getWarningModalForFederatedRooms(
closeModal,
handleConfirm,
Expand All @@ -118,7 +118,7 @@ export const useChangeOwnerAction = (user: Pick<IUser, '_id' | 'username'>, rid:
}

if (!changingOwnRole && loggedUserIsOwner) {
return setModal(() =>
return setModal(
getWarningModalForFederatedRooms(
closeModal,
handleConfirm,
Expand Down

0 comments on commit 6ec661b

Please sign in to comment.