fix: show full member list on update

This commit is contained in:
Paul Makles 2022-01-04 14:40:03 +00:00
parent 270624d5ec
commit b745cdd4d7

View file

@ -1,5 +1,4 @@
/* eslint-disable react-hooks/rules-of-hooks */ /* eslint-disable react-hooks/rules-of-hooks */
import isEqual from "lodash.isequal";
import { reaction } from "mobx"; import { reaction } from "mobx";
import { observer } from "mobx-react-lite"; import { observer } from "mobx-react-lite";
import { useParams } from "react-router-dom"; import { useParams } from "react-router-dom";
@ -9,7 +8,7 @@ import { Channel } from "revolt.js/dist/maps/Channels";
import { Server } from "revolt.js/dist/maps/Servers"; import { Server } from "revolt.js/dist/maps/Servers";
import { User } from "revolt.js/dist/maps/Users"; import { User } from "revolt.js/dist/maps/Users";
import { Inputs, useContext, useEffect, useRef, useState } from "preact/hooks"; import { useContext, useEffect, useState } from "preact/hooks";
import { defer } from "../../../lib/defer"; import { defer } from "../../../lib/defer";
@ -22,15 +21,6 @@ import {
import { GenericSidebarBase } from "../SidebarBase"; import { GenericSidebarBase } from "../SidebarBase";
import MemberList, { MemberListGroup } from "./MemberList"; import MemberList, { MemberListGroup } from "./MemberList";
/*export const Container = styled.div`
padding-top: 48px;
${isTouchscreenDevice &&
css`
padding-top: 0;
`}
`;*/
export default function MemberSidebar() { export default function MemberSidebar() {
const channel = useClient().channels.get( const channel = useClient().channels.get(
useParams<{ channel: string }>().channel, useParams<{ channel: string }>().channel,
@ -48,14 +38,13 @@ export default function MemberSidebar() {
function useEntries( function useEntries(
channel: Channel, channel: Channel,
keys: string[], renderListener: (effect: (keys: string[]) => void) => () => void,
renderListener: (effect: () => void) => () => void,
isServer?: boolean, isServer?: boolean,
) { ) {
const client = channel.client; const client = channel.client;
const [entries, setEntries] = useState<MemberListGroup[]>([]); const [entries, setEntries] = useState<MemberListGroup[]>([]);
function sort() { function sort(keys: string[]) {
defer(() => { defer(() => {
const categories: { [key: string]: [User, string][] } = { const categories: { [key: string]: [User, string][] } = {
online: [], online: [],
@ -170,8 +159,6 @@ function useEntries(
}); });
} }
useEffect(() => sort(), []);
useEffect(() => { useEffect(() => {
return renderListener(sort); return renderListener(sort);
// eslint-disable-next-line // eslint-disable-next-line
@ -182,8 +169,8 @@ function useEntries(
export const GroupMemberSidebar = observer( export const GroupMemberSidebar = observer(
({ channel }: { channel: Channel }) => { ({ channel }: { channel: Channel }) => {
const entries = useEntries(channel, channel.recipient_ids!, (effect) => const entries = useEntries(channel, (effect) =>
reaction(() => channel.recipient_ids, effect), reaction(() => channel.recipient_ids!, effect),
); );
return ( return (
@ -222,7 +209,6 @@ export const ServerMemberSidebar = observer(
const entries = useEntries( const entries = useEntries(
channel, channel,
[...client.members.keys()],
(effect) => reaction(() => [...client.members.keys()], effect), (effect) => reaction(() => [...client.members.keys()], effect),
true, true,
); );