fix: finally fix the members sidebar (real)

This commit is contained in:
Paul Makles 2022-01-04 15:01:53 +00:00
parent 00764b8cc3
commit a09fbe685d

View file

@ -38,7 +38,7 @@ export default function MemberSidebar() {
function useEntries( function useEntries(
channel: Channel, channel: Channel,
renderListener: (effect: (keys: string[]) => void) => () => void, generateKeys: () => string[],
isServer?: boolean, isServer?: boolean,
) { ) {
const client = channel.client; const client = channel.client;
@ -160,18 +160,16 @@ function useEntries(
} }
useEffect(() => { useEffect(() => {
return renderListener(sort); return autorun(() => sort(generateKeys()));
// eslint-disable-next-line // eslint-disable-next-line
}, [renderListener]); }, [generateKeys]);
return entries; return entries;
} }
export const GroupMemberSidebar = observer( export const GroupMemberSidebar = observer(
({ channel }: { channel: Channel }) => { ({ channel }: { channel: Channel }) => {
const entries = useEntries(channel, (effect) => const entries = useEntries(channel, () => channel.recipient_ids!);
autorun(() => effect(channel.recipient_ids!)),
);
return ( return (
<GenericSidebarBase data-scroll-offset="with-padding"> <GenericSidebarBase data-scroll-offset="with-padding">
@ -209,7 +207,7 @@ export const ServerMemberSidebar = observer(
const entries = useEntries( const entries = useEntries(
channel, channel,
(effect) => autorun(() => effect([...client.members.keys()])), () => [...client.members.keys()],
true, true,
); );