mirror of
https://github.com/stoatchat/for-legacy-web.git
synced 2026-03-07 01:15:28 +00:00
feat: add a way to toggle offline users list
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { Link } from "react-router-dom";
|
||||
import { GroupedVirtuoso } from "react-virtuoso";
|
||||
import { Channel } from "revolt.js/dist/maps/Channels";
|
||||
import { User } from "revolt.js/dist/maps/Users";
|
||||
@@ -48,6 +49,10 @@ const NoOomfie = styled.div`
|
||||
font-size: 0.8em;
|
||||
text-align: center;
|
||||
color: var(--secondary-foreground);
|
||||
|
||||
flex-direction: column;
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
`;
|
||||
|
||||
const ItemContent = memo(
|
||||
@@ -128,14 +133,23 @@ export default function MemberList({
|
||||
if (entry.type === "no_offline") {
|
||||
return (
|
||||
<NoOomfie>
|
||||
Offline users temporarily disabled for this server,
|
||||
see issue{" "}
|
||||
<a
|
||||
href="https://github.com/revoltchat/delta/issues/128"
|
||||
target="_blank">
|
||||
#128
|
||||
</a>{" "}
|
||||
for when this will be resolved.
|
||||
<div>
|
||||
Offline users temporarily disabled for this
|
||||
server, see issue{" "}
|
||||
<a
|
||||
href="https://github.com/revoltchat/delta/issues/128"
|
||||
target="_blank">
|
||||
#128
|
||||
</a>{" "}
|
||||
for when this will be resolved.
|
||||
</div>
|
||||
<div>
|
||||
You may re-enable them in{" "}
|
||||
<Link to="/settings/experiments">
|
||||
<a>experiments</a>
|
||||
</Link>
|
||||
.
|
||||
</div>
|
||||
</NoOomfie>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* eslint-disable react-hooks/rules-of-hooks */
|
||||
import { autorun, reaction } from "mobx";
|
||||
import { autorun } from "mobx";
|
||||
import { observer } from "mobx-react-lite";
|
||||
import { useParams } from "react-router-dom";
|
||||
import { Role } from "revolt-api/types/Servers";
|
||||
@@ -10,8 +10,6 @@ import { User } from "revolt.js/dist/maps/Users";
|
||||
|
||||
import { useContext, useEffect, useState } from "preact/hooks";
|
||||
|
||||
import { defer } from "../../../lib/defer";
|
||||
|
||||
import {
|
||||
ClientStatus,
|
||||
StatusContext,
|
||||
@@ -148,7 +146,7 @@ function useEntries(
|
||||
}
|
||||
|
||||
// ! FIXME: Temporary performance fix
|
||||
if (SKIP_OFFLINE.has(channel.server_id!)) {
|
||||
if (shouldSkipOffline(channel.server_id!)) {
|
||||
entries.push({
|
||||
type: "no_offline",
|
||||
users: [null!],
|
||||
@@ -194,7 +192,20 @@ export function resetMemberSidebarFetched() {
|
||||
FETCHED.clear();
|
||||
}
|
||||
|
||||
export const SKIP_OFFLINE = new Set(["01F7ZSBSFHQ8TA81725KQCSDDP"]);
|
||||
const SKIP_OFFLINE = new Set(["01F7ZSBSFHQ8TA81725KQCSDDP"]);
|
||||
|
||||
let SKIP_ENABLED = true;
|
||||
export function setOfflineSkipEnabled(value: boolean) {
|
||||
SKIP_ENABLED = value;
|
||||
}
|
||||
|
||||
function shouldSkipOffline(id: string) {
|
||||
if (SKIP_ENABLED) {
|
||||
return SKIP_OFFLINE.has(id);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
export const ServerMemberSidebar = observer(
|
||||
({ channel }: { channel: Channel }) => {
|
||||
@@ -205,7 +216,7 @@ export const ServerMemberSidebar = observer(
|
||||
const server_id = channel.server_id!;
|
||||
if (status === ClientStatus.ONLINE && !FETCHED.has(server_id)) {
|
||||
channel
|
||||
.server!.syncMembers(SKIP_OFFLINE.has(server_id))
|
||||
.server!.syncMembers(shouldSkipOffline(server_id))
|
||||
.then(() => FETCHED.add(server_id));
|
||||
}
|
||||
// eslint-disable-next-line
|
||||
|
||||
Reference in New Issue
Block a user