diff --git a/src/app/organisms/public-channels/PublicChannels.jsx b/src/app/organisms/public-channels/PublicChannels.jsx index 2f02ba0..624ea48 100644 --- a/src/app/organisms/public-channels/PublicChannels.jsx +++ b/src/app/organisms/public-channels/PublicChannels.jsx @@ -84,7 +84,7 @@ TryJoinWithAlias.propTypes = { onRequestClose: PropTypes.func.isRequired, }; -function PublicChannels({ isOpen, onRequestClose }) { +function PublicChannels({ isOpen, searchTerm, onRequestClose }) { const [isSearching, updateIsSearching] = useState(false); const [isViewMore, updateIsViewMore] = useState(false); const [publicChannels, updatePublicChannels] = useState([]); @@ -97,7 +97,7 @@ function PublicChannels({ isOpen, onRequestClose }) { const userId = initMatrix.matrixClient.getUserId(); async function searchChannels(viewMore) { - let inputChannelName = channelNameRef?.current?.value; + let inputChannelName = channelNameRef?.current?.value || searchTerm; let isInputAlias = false; if (typeof inputChannelName === 'string') { isInputAlias = inputChannelName[0] === '#' && inputChannelName.indexOf(':') > 1; @@ -214,7 +214,7 @@ function PublicChannels({ isOpen, onRequestClose }) {
{ e.preventDefault(); searchChannels(); }}>
- +
@@ -271,8 +271,13 @@ function PublicChannels({ isOpen, onRequestClose }) { ); } +PublicChannels.defaultProps = { + searchTerm: undefined, +}; + PublicChannels.propTypes = { isOpen: PropTypes.bool.isRequired, + searchTerm: PropTypes.string, onRequestClose: PropTypes.func.isRequired, }; diff --git a/src/app/organisms/pw/Windows.jsx b/src/app/organisms/pw/Windows.jsx index 851ed9a..8a0afd3 100644 --- a/src/app/organisms/pw/Windows.jsx +++ b/src/app/organisms/pw/Windows.jsx @@ -11,7 +11,9 @@ import Settings from '../settings/Settings'; function Windows() { const [isInviteList, changeInviteList] = useState(false); - const [isPubilcChannels, changePubilcChannels] = useState(false); + const [publicChannels, changePublicChannels] = useState({ + isOpen: false, searchTerm: undefined, + }); const [isCreateChannel, changeCreateChannel] = useState(false); const [inviteUser, changeInviteUser] = useState({ isOpen: false, roomId: undefined, term: undefined, @@ -21,8 +23,11 @@ function Windows() { function openInviteList() { changeInviteList(true); } - function openPublicChannels() { - changePubilcChannels(true); + function openPublicChannels(searchTerm) { + changePublicChannels({ + isOpen: true, + searchTerm, + }); } function openCreateChannel() { changeCreateChannel(true); @@ -60,8 +65,9 @@ function Windows() { onRequestClose={() => changeInviteList(false)} /> changePubilcChannels(false)} + isOpen={publicChannels.isOpen} + searchTerm={publicChannels.searchTerm} + onRequestClose={() => changePublicChannels({ isOpen: false, searchTerm: undefined })} /> { - this.emit(cons.events.navigation.PUBLIC_CHANNELS_OPENED); + this.emit(cons.events.navigation.PUBLIC_CHANNELS_OPENED, action.searchTerm); }, [cons.actions.navigation.OPEN_CREATE_CHANNEL]: () => { this.emit(cons.events.navigation.CREATE_CHANNEL_OPENED);