MCPcopy Create free account
hub / github.com/Linen-dev/linen.dev / FindChannelModal

Function FindChannelModal

apps/web/ui/FindChannelModal/index.tsx:27–171  ·  view source on GitHub ↗
({
  currentCommunity,
  show,
  close,
  api,
  channels: initialChannels,
  CustomRouterPush,
  onJoinChannel,
  onLeaveChannel,
}: Props)

Source from the content-addressed store, hash-verified

25}
26
27export 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

Callers

nothing calls this directly

Calls 7

setQueryFunction · 0.85
onLeaveChannelFunction · 0.85
onJoinChannelFunction · 0.85
mapMethod · 0.80
successMethod · 0.80
joinChannelMethod · 0.80
errorMethod · 0.65

Tested by

no test coverage detected