Page MenuHomePhorge

D15289.1765047935.diff
No OneTemporary

Size
2 KB
Referenced Files
None
Subscribers
None

D15289.1765047935.diff

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 (
+ <Modal
+ size="fit-content"
+ name="Need another admin"
+ icon="warning-circle"
+ withCloseButton={true}
+ onClose={onClose}
+ >
+ <div className={css.container}>
+ Make somebody else an admin before you leave!
+ </div>
+ </Modal>
+ );
+ }
+
return (
<Modal
size="fit-content"

File Metadata

Mime Type
text/plain
Expires
Sat, Dec 6, 7:05 PM (13 h, 55 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5839779
Default Alt Text
D15289.1765047935.diff (2 KB)

Event Timeline