diff --git a/web/chat/thread-menu.react.js b/web/chat/thread-menu.react.js --- a/web/chat/thread-menu.react.js +++ b/web/chat/thread-menu.react.js @@ -6,7 +6,10 @@ import SWMansionIcon from 'lib/components/swmansion-icon.react.js'; import { usePromoteSidebar } from 'lib/hooks/promote-sidebar.react.js'; import { useLeaveThread } from 'lib/hooks/thread-hooks.js'; -import { childThreadInfos } from 'lib/selectors/thread-selectors.js'; +import { + childThreadInfos, + otherUsersButNoOtherAdmins, +} from 'lib/selectors/thread-selectors.js'; import { threadIsChannel, useThreadHasPermission, @@ -208,6 +211,9 @@ popModal(); }, [leaveThread, popModal, threadInfo]); + const otherUsersButNoOtherAdminsValue = useSelector( + otherUsersButNoOtherAdmins(threadInfo.id), + ); const onClickLeaveThread = React.useCallback( () => pushModal( @@ -215,9 +221,16 @@ threadInfo={threadInfo} onClose={popModal} onConfirm={onConfirmLeaveThread} + otherUsersButNoOtherAdmins={otherUsersButNoOtherAdminsValue} />, ), - [popModal, onConfirmLeaveThread, pushModal, threadInfo], + [ + pushModal, + threadInfo, + popModal, + onConfirmLeaveThread, + otherUsersButNoOtherAdminsValue, + ], ); const canLeaveThread = useThreadHasPermission( diff --git a/web/modals/threads/confirm-leave-thread-modal.react.js b/web/modals/threads/confirm-leave-thread-modal.react.js --- a/web/modals/threads/confirm-leave-thread-modal.react.js +++ b/web/modals/threads/confirm-leave-thread-modal.react.js @@ -13,9 +13,10 @@ +threadInfo: ThreadInfo, +onClose: () => void, +onConfirm: () => void, + +otherUsersButNoOtherAdmins: boolean, }; function ConfirmLeaveThreadModal(props: Props): React.Node { - const { threadInfo, onClose, onConfirm } = props; + const { threadInfo, onClose, onConfirm, otherUsersButNoOtherAdmins } = props; const { uiName } = useResolvedThreadInfo(threadInfo); const primaryButton = React.useMemo( @@ -41,6 +42,22 @@ [onClose], ); + if (otherUsersButNoOtherAdmins) { + return ( + + + Make somebody else an admin before you leave! + + + ); + } + return (