Page MenuHomePhabricator

D9558.id32318.diff
No OneTemporary

D9558.id32318.diff

diff --git a/web/chat/chat-thread-list.react.js b/web/chat/chat-thread-list.react.js
--- a/web/chat/chat-thread-list.react.js
+++ b/web/chat/chat-thread-list.react.js
@@ -6,7 +6,10 @@
import AutoSizer from 'react-virtualized-auto-sizer';
import { VariableSizeList } from 'react-window';
+import { useModalContext } from 'lib/components/modal-provider.react.js';
+import genesis from 'lib/facts/genesis.js';
import type { ChatThreadItem } from 'lib/selectors/chat-selectors.js';
+import { threadInfoSelector } from 'lib/selectors/thread-selectors.js';
import { emptyItemText } from 'lib/shared/thread-utils.js';
import ChatThreadListItem from './chat-thread-list-item.react.js';
@@ -15,6 +18,7 @@
import { ThreadListContext } from './thread-list-provider.js';
import BackgroundIllustration from '../assets/background-illustration.react.js';
import Button from '../components/button.react.js';
+import ComposeSubchannelModal from '../modals/threads/create/compose-subchannel-modal.react.js';
import { useSelector } from '../redux/redux-utils.js';
import { useOnClickNewThread } from '../selectors/thread-selectors.js';
@@ -68,6 +72,37 @@
const communityID = useSelector(state => state.communityPickerStore.chat);
+ const communityThreadInfo = useSelector(state => {
+ if (!communityID) {
+ return null;
+ }
+ return threadInfoSelector(state)[communityID];
+ });
+
+ const { pushModal, popModal } = useModalContext();
+
+ const onClickCreateSubchannel = React.useCallback(() => {
+ if (!communityThreadInfo) {
+ return null;
+ }
+ return pushModal(
+ <ComposeSubchannelModal
+ parentThreadInfo={communityThreadInfo}
+ onClose={popModal}
+ />,
+ );
+ }, [popModal, pushModal, communityThreadInfo]);
+
+ const isChatCreation = !communityID || communityID === genesis.id;
+
+ const onClickCreate = isChatCreation
+ ? onClickNewThread
+ : onClickCreateSubchannel;
+
+ const createButtonText = isChatCreation
+ ? 'Create new chat'
+ : 'Create new channel';
+
const threadListContainerRef = React.useRef();
const threads = React.useMemo(
@@ -132,9 +167,9 @@
<Button
variant="filled"
disabled={isThreadCreation}
- onClick={onClickNewThread}
+ onClick={onClickCreate}
>
- Create new chat
+ {createButtonText}
</Button>
</div>
</>

File Metadata

Mime Type
text/plain
Expires
Tue, Nov 26, 2:28 AM (21 h, 8 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2582094
Default Alt Text
D9558.id32318.diff (2 KB)

Event Timeline