chore: disable offline users in lounge server

This commit is contained in:
Paul Makles 2022-01-10 23:25:48 +00:00
parent af8cc984a9
commit c6cc1f3672
4 changed files with 63 additions and 23 deletions

View file

@ -144,7 +144,7 @@
"react-virtualized-auto-sizer": "^1.0.5", "react-virtualized-auto-sizer": "^1.0.5",
"react-virtuoso": "^1.10.4", "react-virtuoso": "^1.10.4",
"revolt-api": "0.5.3-alpha.10", "revolt-api": "0.5.3-alpha.10",
"revolt.js": "5.2.4", "revolt.js": "5.2.5",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"sass": "^1.35.1", "sass": "^1.35.1",
"shade-blend-color": "^1.0.0", "shade-blend-color": "^1.0.0",

View file

@ -6,16 +6,17 @@ import styled, { css } from "styled-components";
import { Text } from "preact-i18n"; import { Text } from "preact-i18n";
import { memo } from "preact/compat"; import { memo } from "preact/compat";
import { internalEmit } from "../../../lib/eventEmitter";
import { import {
Screen, Screen,
useIntermediate, useIntermediate,
} from "../../../context/intermediate/Intermediate"; } from "../../../context/intermediate/Intermediate";
import { UserButton } from "../items/ButtonItem"; import { UserButton } from "../items/ButtonItem";
import { internalEmit } from "../../../lib/eventEmitter";
export type MemberListGroup = { export type MemberListGroup = {
type: "online" | "offline" | "role"; type: "online" | "offline" | "role" | "no_offline";
name?: string; name?: string;
users: User[]; users: User[];
}; };
@ -39,6 +40,16 @@ const ListCategory = styled.div<{ first?: boolean }>`
`} `}
`; `;
// ! FIXME: temporary performance fix
const NoOomfie = styled.div`
padding: 4px;
padding-bottom: 12px;
font-size: 0.8em;
text-align: center;
color: var(--secondary-foreground);
`;
const ItemContent = memo( const ItemContent = memo(
({ ({
item, item,
@ -54,7 +65,7 @@ const ItemContent = memo(
user={item} user={item}
margin margin
context={context} context={context}
onClick={e => { onClick={(e) => {
if (e.shiftKey) { if (e.shiftKey) {
internalEmit( internalEmit(
"MessageBox", "MessageBox",
@ -62,12 +73,13 @@ const ItemContent = memo(
`<@${item._id}>`, `<@${item._id}>`,
"mention", "mention",
); );
} else[ } else
[
openScreen({ openScreen({
id: "profile", id: "profile",
user_id: item._id, user_id: item._id,
}) }),
] ];
}} }}
/> />
), ),
@ -86,18 +98,22 @@ export default function MemberList({
<GroupedVirtuoso <GroupedVirtuoso
groupCounts={entries.map((x) => x.users.length)} groupCounts={entries.map((x) => x.users.length)}
groupContent={(index) => { groupContent={(index) => {
const type = entries[index].type; const entry = entries[index];
return ( return (
<ListCategory first={index === 0}> <ListCategory first={index === 0}>
{type === "role" ? ( {entry.type === "role" ? (
<>{entries[index].name}</> <>{entry.name}</>
) : type === "online" ? ( ) : entry.type === "online" ? (
<Text id="app.status.online" /> <Text id="app.status.online" />
) : ( ) : (
<Text id="app.status.offline" /> <Text id="app.status.offline" />
)} )}
{entry.type !== "no_offline" && (
<>
{" - "} {" - "}
{entries[index].users.length} {entry.users.length}
</>
)}
</ListCategory> </ListCategory>
); );
}} }}
@ -108,7 +124,23 @@ export default function MemberList({
.slice(0, groupIndex) .slice(0, groupIndex)
.reduce((a, b) => a + b.users.length, 0); .reduce((a, b) => a + b.users.length, 0);
const item = entries[groupIndex].users[relativeIndex]; const entry = entries[groupIndex];
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.
</NoOomfie>
);
}
const item = entry.users[relativeIndex];
if (!item) return null; if (!item) return null;
return ( return (

View file

@ -147,7 +147,13 @@ function useEntries(
}); });
} }
if (categories.offline.length > 0) { // ! FIXME: Temporary performance fix
if (SKIP_OFFLINE.has(channel.server_id!)) {
entries.push({
type: "no_offline",
users: [null!],
});
} else if (categories.offline.length > 0) {
entries.push({ entries.push({
type: "offline", type: "offline",
users: categories.offline.map((x) => x[0]), users: categories.offline.map((x) => x[0]),
@ -188,6 +194,8 @@ export function resetMemberSidebarFetched() {
FETCHED.clear(); FETCHED.clear();
} }
export const SKIP_OFFLINE = new Set(["01F7ZSBSFHQ8TA81725KQCSDDP"]);
export const ServerMemberSidebar = observer( export const ServerMemberSidebar = observer(
({ channel }: { channel: Channel }) => { ({ channel }: { channel: Channel }) => {
const client = useClient(); const client = useClient();
@ -197,7 +205,7 @@ export const ServerMemberSidebar = observer(
const server_id = channel.server_id!; const server_id = channel.server_id!;
if (status === ClientStatus.ONLINE && !FETCHED.has(server_id)) { if (status === ClientStatus.ONLINE && !FETCHED.has(server_id)) {
channel channel
.server!.syncMembers() .server!.syncMembers(SKIP_OFFLINE.has(server_id))
.then(() => FETCHED.add(server_id)); .then(() => FETCHED.add(server_id));
} }
// eslint-disable-next-line // eslint-disable-next-line

View file

@ -3815,10 +3815,10 @@ revolt-api@^0.5.3-alpha.9:
resolved "https://registry.yarnpkg.com/revolt-api/-/revolt-api-0.5.3-alpha.9.tgz#46e75b7d8f9c6702df39039b829dddbb7897f237" resolved "https://registry.yarnpkg.com/revolt-api/-/revolt-api-0.5.3-alpha.9.tgz#46e75b7d8f9c6702df39039b829dddbb7897f237"
integrity sha512-L8K9uPV3ME8bLdtWm8L9iPQvFM0GghA+5LzmWFjd6Gbn56u22ZYub2lABi4iHrWgeA2X41dGSsuSBgHSlts9Og== integrity sha512-L8K9uPV3ME8bLdtWm8L9iPQvFM0GghA+5LzmWFjd6Gbn56u22ZYub2lABi4iHrWgeA2X41dGSsuSBgHSlts9Og==
revolt.js@5.2.4: revolt.js@5.2.5:
version "5.2.4" version "5.2.5"
resolved "https://registry.yarnpkg.com/revolt.js/-/revolt.js-5.2.4.tgz#810a6c6209fc1836acfcab598263a33f2f816751" resolved "https://registry.yarnpkg.com/revolt.js/-/revolt.js-5.2.5.tgz#ffd2b759a807f3430f6018459acdf57e95f842a5"
integrity sha512-Jm1uS5orTg1pnttmlrBm5hxB0C0KhOgnQg7MqZU4Zxu/kWns2nvozVmG/O/4jfky6xeqMjZrZOXAOZIHUM5T4Q== integrity sha512-rS6FOc7XPfe/BuGnuCvM1N/CEGMtR/bHy4le5154MF9bbpebLw205niq7rq5TMsXT/f7J4qlOI7xX0rvKprn6w==
dependencies: dependencies:
"@insertish/exponential-backoff" "3.1.0-patch.0" "@insertish/exponential-backoff" "3.1.0-patch.0"
"@insertish/isomorphic-ws" "^4.0.1" "@insertish/isomorphic-ws" "^4.0.1"