({
currentCommunity,
show,
close,
api,
channels: initialChannels,
CustomRouterPush,
onJoinChannel,
onLeaveChannel,
}: Props)
| 25 | } |
| 26 | |
| 27 | export default function FindChannelModal({ |
| 28 | currentCommunity, |
| 29 | show, |
| 30 | close, |
| 31 | api, |
| 32 | channels: initialChannels, |
| 33 | CustomRouterPush, |
| 34 | onJoinChannel, |
| 35 | onLeaveChannel, |
| 36 | }: Props) { |
| 37 | const [loading, setLoading] = useState(true); |
| 38 | const [query, setQuery] = useState(''); |
| 39 | const [channels, setChannels] = useState<SerializedChannel[]>([]); |
| 40 | const visibleChannelIds = initialChannels.map(({ id }) => id); |
| 41 | |
| 42 | useEffect(() => { |
| 43 | let mounted = true; |
| 44 | |
| 45 | setTimeout(() => { |
| 46 | api |
| 47 | .getChannels({ |
| 48 | accountId: currentCommunity.id, |
| 49 | }) |
| 50 | .then((response: any) => { |
| 51 | if (mounted) { |
| 52 | setChannels(response.channels); |
| 53 | setLoading(false); |
| 54 | } |
| 55 | }) |
| 56 | .catch(() => { |
| 57 | if (mounted) { |
| 58 | setLoading(false); |
| 59 | } |
| 60 | }); |
| 61 | }, 200); |
| 62 | |
| 63 | return () => { |
| 64 | mounted = false; |
| 65 | }; |
| 66 | }, []); |
| 67 | |
| 68 | return ( |
| 69 | <Modal open={show} close={close} position="top" size="lg"> |
| 70 | <div className={styles.title}> |
| 71 | <H3>Find a channel</H3> |
| 72 | |
| 73 | <div className={styles.close} onClick={close}> |
| 74 | <FiX /> |
| 75 | </div> |
| 76 | </div> |
| 77 | {loading ? ( |
| 78 | <Spinner className={styles.spinner} /> |
| 79 | ) : ( |
| 80 | <> |
| 81 | <TextInput |
| 82 | autoFocus |
| 83 | id="channelName" |
| 84 | required |
nothing calls this directly
no test coverage detected