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([]);
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;
<div className="public-channels">
<form className="public-channels__form" onSubmit={(e) => { e.preventDefault(); searchChannels(); }}>
<div className="public-channels__input-wrapper">
- <Input forwardRef={channelNameRef} label="Channel name or alias" />
+ <Input value={searchTerm} forwardRef={channelNameRef} label="Channel name or alias" />
<Input forwardRef={hsRef} value={userId.slice(userId.indexOf(':') + 1)} label="Homeserver" required />
</div>
<Button disabled={isSearching} iconSrc={HashSearchIC} variant="primary" type="submit">Search</Button>
);
}
+PublicChannels.defaultProps = {
+ searchTerm: undefined,
+};
+
PublicChannels.propTypes = {
isOpen: PropTypes.bool.isRequired,
+ searchTerm: PropTypes.string,
onRequestClose: PropTypes.func.isRequired,
};
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,
function openInviteList() {
changeInviteList(true);
}
- function openPublicChannels() {
- changePubilcChannels(true);
+ function openPublicChannels(searchTerm) {
+ changePublicChannels({
+ isOpen: true,
+ searchTerm,
+ });
}
function openCreateChannel() {
changeCreateChannel(true);
onRequestClose={() => changeInviteList(false)}
/>
<PublicChannels
- isOpen={isPubilcChannels}
- onRequestClose={() => changePubilcChannels(false)}
+ isOpen={publicChannels.isOpen}
+ searchTerm={publicChannels.searchTerm}
+ onRequestClose={() => changePublicChannels({ isOpen: false, searchTerm: undefined })}
/>
<CreateChannel
isOpen={isCreateChannel}
});
}
-function openPublicChannels() {
+function openPublicChannels(searchTerm) {
appDispatcher.dispatch({
type: cons.actions.navigation.OPEN_PUBLIC_CHANNELS,
+ searchTerm,
});
}
this.emit(cons.events.navigation.INVITE_LIST_OPENED);
},
[cons.actions.navigation.OPEN_PUBLIC_CHANNELS]: () => {
- 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);