mirror of
https://github.com/revoltchat/revite.git
synced 2024-12-24 22:52:09 -05:00
chore: disable offline users in lounge server
This commit is contained in:
parent
af8cc984a9
commit
c6cc1f3672
4 changed files with 63 additions and 23 deletions
|
@ -144,7 +144,7 @@
|
|||
"react-virtualized-auto-sizer": "^1.0.5",
|
||||
"react-virtuoso": "^1.10.4",
|
||||
"revolt-api": "0.5.3-alpha.10",
|
||||
"revolt.js": "5.2.4",
|
||||
"revolt.js": "5.2.5",
|
||||
"rimraf": "^3.0.2",
|
||||
"sass": "^1.35.1",
|
||||
"shade-blend-color": "^1.0.0",
|
||||
|
|
|
@ -6,16 +6,17 @@ import styled, { css } from "styled-components";
|
|||
import { Text } from "preact-i18n";
|
||||
import { memo } from "preact/compat";
|
||||
|
||||
import { internalEmit } from "../../../lib/eventEmitter";
|
||||
|
||||
import {
|
||||
Screen,
|
||||
useIntermediate,
|
||||
} from "../../../context/intermediate/Intermediate";
|
||||
|
||||
import { UserButton } from "../items/ButtonItem";
|
||||
import { internalEmit } from "../../../lib/eventEmitter";
|
||||
|
||||
export type MemberListGroup = {
|
||||
type: "online" | "offline" | "role";
|
||||
type: "online" | "offline" | "role" | "no_offline";
|
||||
name?: string;
|
||||
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(
|
||||
({
|
||||
item,
|
||||
|
@ -54,7 +65,7 @@ const ItemContent = memo(
|
|||
user={item}
|
||||
margin
|
||||
context={context}
|
||||
onClick={e => {
|
||||
onClick={(e) => {
|
||||
if (e.shiftKey) {
|
||||
internalEmit(
|
||||
"MessageBox",
|
||||
|
@ -62,12 +73,13 @@ const ItemContent = memo(
|
|||
`<@${item._id}>`,
|
||||
"mention",
|
||||
);
|
||||
} else[
|
||||
openScreen({
|
||||
id: "profile",
|
||||
user_id: item._id,
|
||||
})
|
||||
]
|
||||
} else
|
||||
[
|
||||
openScreen({
|
||||
id: "profile",
|
||||
user_id: item._id,
|
||||
}),
|
||||
];
|
||||
}}
|
||||
/>
|
||||
),
|
||||
|
@ -86,18 +98,22 @@ export default function MemberList({
|
|||
<GroupedVirtuoso
|
||||
groupCounts={entries.map((x) => x.users.length)}
|
||||
groupContent={(index) => {
|
||||
const type = entries[index].type;
|
||||
const entry = entries[index];
|
||||
return (
|
||||
<ListCategory first={index === 0}>
|
||||
{type === "role" ? (
|
||||
<>{entries[index].name}</>
|
||||
) : type === "online" ? (
|
||||
{entry.type === "role" ? (
|
||||
<>{entry.name}</>
|
||||
) : entry.type === "online" ? (
|
||||
<Text id="app.status.online" />
|
||||
) : (
|
||||
<Text id="app.status.offline" />
|
||||
)}
|
||||
{" - "}
|
||||
{entries[index].users.length}
|
||||
{entry.type !== "no_offline" && (
|
||||
<>
|
||||
{" - "}
|
||||
{entry.users.length}
|
||||
</>
|
||||
)}
|
||||
</ListCategory>
|
||||
);
|
||||
}}
|
||||
|
@ -108,7 +124,23 @@ export default function MemberList({
|
|||
.slice(0, groupIndex)
|
||||
.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;
|
||||
|
||||
return (
|
||||
|
|
|
@ -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({
|
||||
type: "offline",
|
||||
users: categories.offline.map((x) => x[0]),
|
||||
|
@ -188,6 +194,8 @@ export function resetMemberSidebarFetched() {
|
|||
FETCHED.clear();
|
||||
}
|
||||
|
||||
export const SKIP_OFFLINE = new Set(["01F7ZSBSFHQ8TA81725KQCSDDP"]);
|
||||
|
||||
export const ServerMemberSidebar = observer(
|
||||
({ channel }: { channel: Channel }) => {
|
||||
const client = useClient();
|
||||
|
@ -197,7 +205,7 @@ export const ServerMemberSidebar = observer(
|
|||
const server_id = channel.server_id!;
|
||||
if (status === ClientStatus.ONLINE && !FETCHED.has(server_id)) {
|
||||
channel
|
||||
.server!.syncMembers()
|
||||
.server!.syncMembers(SKIP_OFFLINE.has(server_id))
|
||||
.then(() => FETCHED.add(server_id));
|
||||
}
|
||||
// eslint-disable-next-line
|
||||
|
|
|
@ -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"
|
||||
integrity sha512-L8K9uPV3ME8bLdtWm8L9iPQvFM0GghA+5LzmWFjd6Gbn56u22ZYub2lABi4iHrWgeA2X41dGSsuSBgHSlts9Og==
|
||||
|
||||
revolt.js@5.2.4:
|
||||
version "5.2.4"
|
||||
resolved "https://registry.yarnpkg.com/revolt.js/-/revolt.js-5.2.4.tgz#810a6c6209fc1836acfcab598263a33f2f816751"
|
||||
integrity sha512-Jm1uS5orTg1pnttmlrBm5hxB0C0KhOgnQg7MqZU4Zxu/kWns2nvozVmG/O/4jfky6xeqMjZrZOXAOZIHUM5T4Q==
|
||||
revolt.js@5.2.5:
|
||||
version "5.2.5"
|
||||
resolved "https://registry.yarnpkg.com/revolt.js/-/revolt.js-5.2.5.tgz#ffd2b759a807f3430f6018459acdf57e95f842a5"
|
||||
integrity sha512-rS6FOc7XPfe/BuGnuCvM1N/CEGMtR/bHy4le5154MF9bbpebLw205niq7rq5TMsXT/f7J4qlOI7xX0rvKprn6w==
|
||||
dependencies:
|
||||
"@insertish/exponential-backoff" "3.1.0-patch.0"
|
||||
"@insertish/isomorphic-ws" "^4.0.1"
|
||||
|
|
Loading…
Reference in a new issue