Skip to content

Commit

Permalink
[web] Create new chat button creates chat in GENESIS community only
Browse files Browse the repository at this point in the history
Summary:
Reopening after previous commit failed build. Just required a `git pull --rebase`.

Changed create chat button when in non-GENESIS community to begin create channel experience.
Create `onClickSubChannel` which pushes `ComposeSubchannelModal` when `communityID` does not equal `genesis.id`.
Added conditional to change `"Create new chat"` to '"Create new channel"' when in non-GENESIS community.

Test Plan: Verified working on local web, `flow` ran successfully

Reviewers: ashoat

Reviewed By: ashoat

Subscribers: tomek

Differential Revision: https://phab.comm.dev/D9567
  • Loading branch information
wyilio committed Oct 23, 2023
1 parent 5ddc929 commit d163a4c
Showing 1 changed file with 37 additions and 2 deletions.
39 changes: 37 additions & 2 deletions web/chat/chat-thread-list.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import * as React from 'react';
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';
Expand All @@ -15,6 +18,7 @@ import css from './chat-thread-list.css';
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';

Expand Down Expand Up @@ -68,6 +72,37 @@ function ChatThreadList(): React.Node {

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(
Expand Down Expand Up @@ -132,9 +167,9 @@ function ChatThreadList(): React.Node {
<Button
variant="filled"
disabled={isThreadCreation}
onClick={onClickNewThread}
onClick={onClickCreate}
>
Create new chat
{createButtonText}
</Button>
</div>
</>
Expand Down

0 comments on commit d163a4c

Please sign in to comment.