mirror of
https://github.com/revoltchat/revite.git
synced 2024-12-24 22:52:09 -05:00
Render server categories.
This commit is contained in:
parent
47f6404f44
commit
e4786e7230
3 changed files with 44 additions and 25 deletions
|
@ -77,7 +77,7 @@
|
||||||
"react-scroll": "^1.8.2",
|
"react-scroll": "^1.8.2",
|
||||||
"react-tippy": "^1.4.0",
|
"react-tippy": "^1.4.0",
|
||||||
"redux": "^4.1.0",
|
"redux": "^4.1.0",
|
||||||
"revolt.js": "4.3.3-alpha.1",
|
"revolt.js": "4.3.3-alpha.2",
|
||||||
"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",
|
||||||
|
|
|
@ -1,14 +1,10 @@
|
||||||
import { Link } from "react-router-dom";
|
|
||||||
import { Settings } from "@styled-icons/feather";
|
|
||||||
import { Redirect, useParams } from "react-router";
|
import { Redirect, useParams } from "react-router";
|
||||||
import { ChannelButton } from "../items/ButtonItem";
|
import { ChannelButton } from "../items/ButtonItem";
|
||||||
import { Channels } from "revolt.js/dist/api/objects";
|
import { Channels } from "revolt.js/dist/api/objects";
|
||||||
import { ServerPermission } from "revolt.js/dist/api/permissions";
|
|
||||||
import { Unreads } from "../../../redux/reducers/unreads";
|
import { Unreads } from "../../../redux/reducers/unreads";
|
||||||
import { WithDispatcher } from "../../../redux/reducers";
|
import { WithDispatcher } from "../../../redux/reducers";
|
||||||
import { useChannels, useForceUpdate, useServer, useServerPermission } from "../../../context/revoltjs/hooks";
|
import { useChannels, useForceUpdate, useServer } from "../../../context/revoltjs/hooks";
|
||||||
import { mapChannelWithUnread, useUnreads } from "./common";
|
import { mapChannelWithUnread, useUnreads } from "./common";
|
||||||
import Header from '../../ui/Header';
|
|
||||||
import ConnectionStatus from '../items/ConnectionStatus';
|
import ConnectionStatus from '../items/ConnectionStatus';
|
||||||
import { connectState } from "../../../redux/connector";
|
import { connectState } from "../../../redux/connector";
|
||||||
import PaintCounter from "../../../lib/PaintCounter";
|
import PaintCounter from "../../../lib/PaintCounter";
|
||||||
|
@ -16,6 +12,7 @@ import styled from "styled-components";
|
||||||
import { attachContextMenu } from 'preact-context-menu';
|
import { attachContextMenu } from 'preact-context-menu';
|
||||||
import ServerHeader from "../../common/ServerHeader";
|
import ServerHeader from "../../common/ServerHeader";
|
||||||
import { useEffect } from "preact/hooks";
|
import { useEffect } from "preact/hooks";
|
||||||
|
import Category from "../../ui/Category";
|
||||||
import ConditionalLink from "../../../lib/ConditionalLink";
|
import ConditionalLink from "../../../lib/ConditionalLink";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
|
@ -66,16 +63,16 @@ function ServerSidebar(props: Props & WithDispatcher) {
|
||||||
});
|
});
|
||||||
}, [ channel_id ]);
|
}, [ channel_id ]);
|
||||||
|
|
||||||
return (
|
let uncategorised = new Set(server.channels);
|
||||||
<ServerBase>
|
let elements = [];
|
||||||
<ServerHeader server={server} ctx={ctx} />
|
function addChannel(id: string) {
|
||||||
<ConnectionStatus />
|
const entry = channels.find(x => x._id === id);
|
||||||
<ServerList onContextMenu={attachContextMenu('Menu', { server_list: server._id })}>
|
if (!entry) return;
|
||||||
{channels.map(entry => {
|
|
||||||
const active = channel?._id === entry._id;
|
const active = channel?._id === entry._id;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ConditionalLink active={active} to={`/server/${server._id}/channel/${entry._id}`}>
|
<ConditionalLink active={active} to={`/server/${server!._id}/channel/${entry._id}`}>
|
||||||
<ChannelButton
|
<ChannelButton
|
||||||
key={entry._id}
|
key={entry._id}
|
||||||
channel={entry}
|
channel={entry}
|
||||||
|
@ -85,7 +82,29 @@ function ServerSidebar(props: Props & WithDispatcher) {
|
||||||
/>
|
/>
|
||||||
</ConditionalLink>
|
</ConditionalLink>
|
||||||
);
|
);
|
||||||
})}
|
}
|
||||||
|
|
||||||
|
if (server.categories) {
|
||||||
|
for (let category of server.categories) {
|
||||||
|
elements.push(<Category text={category.title} />);
|
||||||
|
|
||||||
|
for (let id of category.channels) {
|
||||||
|
uncategorised.delete(id);
|
||||||
|
elements.push(addChannel(id));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let id of uncategorised) {
|
||||||
|
elements.unshift(addChannel(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ServerBase>
|
||||||
|
<ServerHeader server={server} ctx={ctx} />
|
||||||
|
<ConnectionStatus />
|
||||||
|
<ServerList onContextMenu={attachContextMenu('Menu', { server_list: server._id })}>
|
||||||
|
{ elements }
|
||||||
</ServerList>
|
</ServerList>
|
||||||
<PaintCounter small />
|
<PaintCounter small />
|
||||||
</ServerBase>
|
</ServerBase>
|
||||||
|
|
|
@ -3412,10 +3412,10 @@ reusify@^1.0.4:
|
||||||
resolved "https://registry.yarnpkg.com/reusify/-/reusify-1.0.4.tgz#90da382b1e126efc02146e90845a88db12925d76"
|
resolved "https://registry.yarnpkg.com/reusify/-/reusify-1.0.4.tgz#90da382b1e126efc02146e90845a88db12925d76"
|
||||||
integrity sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==
|
integrity sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==
|
||||||
|
|
||||||
revolt.js@4.3.3-alpha.1:
|
revolt.js@4.3.3-alpha.2:
|
||||||
version "4.3.3-alpha.1"
|
version "4.3.3-alpha.2"
|
||||||
resolved "https://registry.yarnpkg.com/revolt.js/-/revolt.js-4.3.3-alpha.1.tgz#b60a18e5cbe9f2c569e7f46974450931826e10d4"
|
resolved "https://registry.yarnpkg.com/revolt.js/-/revolt.js-4.3.3-alpha.2.tgz#1fb876205d74712c45e5f022624ac8d176ab01a1"
|
||||||
integrity sha512-MxjTOWqg83cLYdpuqLCl3nOTD+jFxSSjrnvczuijam1YjeZ3IB27C6G4Qar3BwMn7B+zH8MgEDecW3YBmKBpIw==
|
integrity sha512-/irTDDtBj63yQtpBk1asnqCNacc+HQXcz0jBOBk1VaOeDsjE6lTO2tGue6wFAG76AL89z9bziQbHIa6cQmWIjg==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@insertish/mutable" "1.1.0"
|
"@insertish/mutable" "1.1.0"
|
||||||
axios "^0.19.2"
|
axios "^0.19.2"
|
||||||
|
|
Loading…
Reference in a new issue