mirror of
https://github.com/revoltchat/revite.git
synced 2024-11-09 16:53:36 -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(
|
export const ServerMemberSidebar = observer(
|
||||||
({ channel }: { channel: Channel }) => {
|
({ channel }: { channel: Channel }) => {
|
||||||
const client = useClient();
|
const client = useClient();
|
||||||
const status = useContext(StatusContext);
|
const status = useContext(StatusContext);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (status === ClientStatus.ONLINE) {
|
const server_id = channel.server_id!;
|
||||||
channel.server!.fetchMembers();
|
if (status === ClientStatus.ONLINE && !FETCHED.has(server_id)) {
|
||||||
|
channel
|
||||||
|
.server!.fetchMembers()
|
||||||
|
.then(() => FETCHED.add(server_id));
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
}, [status, channel.server_id]);
|
}, [status, channel.server_id]);
|
||||||
|
|
|
@ -4,6 +4,7 @@ import { StateUpdater } from "preact/hooks";
|
||||||
|
|
||||||
import Auth from "../../mobx/stores/Auth";
|
import Auth from "../../mobx/stores/Auth";
|
||||||
|
|
||||||
|
import { resetMemberSidebarFetched } from "../../components/navigation/right/MemberSidebar";
|
||||||
import { ClientStatus } from "./RevoltClient";
|
import { ClientStatus } from "./RevoltClient";
|
||||||
|
|
||||||
export let preventReconnect = false;
|
export let preventReconnect = false;
|
||||||
|
@ -43,7 +44,10 @@ export function registerEvents(
|
||||||
attemptReconnect();
|
attemptReconnect();
|
||||||
},
|
},
|
||||||
|
|
||||||
ready: () => setStatus(ClientStatus.ONLINE),
|
ready: () => {
|
||||||
|
resetMemberSidebarFetched();
|
||||||
|
setStatus(ClientStatus.ONLINE);
|
||||||
|
},
|
||||||
|
|
||||||
logout: () => {
|
logout: () => {
|
||||||
auth.logout();
|
auth.logout();
|
||||||
|
|
Loading…
Reference in a new issue