mirror of
https://github.com/revoltchat/revite.git
synced 2024-11-25 08:30:58 -05:00
fix(sidebar): don't keep refetching server members
This commit is contained in:
parent
3baf82ca94
commit
fc91a75acb
2 changed files with 17 additions and 3 deletions
|
@ -179,14 +179,24 @@ export const GroupMemberSidebar = observer(
|
|||
},
|
||||
);
|
||||
|
||||
// ! FIXME: this is temporary code until we get lazy guilds like subscriptions
|
||||
const FETCHED: Set<String> = new Set();
|
||||
|
||||
export function resetMemberSidebarFetched() {
|
||||
FETCHED.clear();
|
||||
}
|
||||
|
||||
export const ServerMemberSidebar = observer(
|
||||
({ channel }: { channel: Channel }) => {
|
||||
const client = useClient();
|
||||
const status = useContext(StatusContext);
|
||||
|
||||
useEffect(() => {
|
||||
if (status === ClientStatus.ONLINE) {
|
||||
channel.server!.fetchMembers();
|
||||
const server_id = channel.server_id!;
|
||||
if (status === ClientStatus.ONLINE && !FETCHED.has(server_id)) {
|
||||
channel
|
||||
.server!.fetchMembers()
|
||||
.then(() => FETCHED.add(server_id));
|
||||
}
|
||||
// eslint-disable-next-line
|
||||
}, [status, channel.server_id]);
|
||||
|
|
|
@ -4,6 +4,7 @@ import { StateUpdater } from "preact/hooks";
|
|||
|
||||
import Auth from "../../mobx/stores/Auth";
|
||||
|
||||
import { resetMemberSidebarFetched } from "../../components/navigation/right/MemberSidebar";
|
||||
import { ClientStatus } from "./RevoltClient";
|
||||
|
||||
export let preventReconnect = false;
|
||||
|
@ -43,7 +44,10 @@ export function registerEvents(
|
|||
attemptReconnect();
|
||||
},
|
||||
|
||||
ready: () => setStatus(ClientStatus.ONLINE),
|
||||
ready: () => {
|
||||
resetMemberSidebarFetched();
|
||||
setStatus(ClientStatus.ONLINE);
|
||||
},
|
||||
|
||||
logout: () => {
|
||||
auth.logout();
|
||||
|
|
Loading…
Reference in a new issue