mirror of
https://github.com/spacebarchat/client.git
synced 2024-11-25 11:42:30 +01:00
just remove channel sorting for now
This commit is contained in:
parent
fb36df86b7
commit
0b756e4023
@ -12,10 +12,10 @@ function ChannelList() {
|
||||
const app = useAppStore();
|
||||
|
||||
if (!app.activeGuild || !app.activeChannel) return null;
|
||||
const { channelsSorted } = app.activeGuild;
|
||||
const { channels } = app.activeGuild;
|
||||
|
||||
const rowRenderer = ({ index, key, style }: ListRowProps) => {
|
||||
const item = channelsSorted[index];
|
||||
const item = channels[index];
|
||||
|
||||
const active = app.activeChannelId === item.id;
|
||||
const isCategory = item.type === ChannelType.GuildCategory;
|
||||
@ -38,9 +38,9 @@ function ChannelList() {
|
||||
<List
|
||||
height={height}
|
||||
overscanRowCount={2}
|
||||
rowCount={channelsSorted.length}
|
||||
rowCount={channels.length}
|
||||
rowHeight={({ index }) => {
|
||||
const item = channelsSorted[index];
|
||||
const item = channels[index];
|
||||
if (item.type === ChannelType.GuildCategory) {
|
||||
return 44;
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ function GuildItem({ guild, active }: Props) {
|
||||
]);
|
||||
|
||||
const doNavigate = () => {
|
||||
const channel = guild.channelsSorted.find((x) => {
|
||||
const channel = guild.channels.find((x) => {
|
||||
const permission = Permissions.getPermission(app.account!.id, guild, x);
|
||||
return permission.has("VIEW_CHANNEL") && x.type !== ChannelType.GuildCategory;
|
||||
});
|
||||
|
@ -1,6 +1,5 @@
|
||||
import type { Snowflake } from "@spacebarchat/spacebar-api-types/globals";
|
||||
import {
|
||||
ChannelType,
|
||||
type APIChannel,
|
||||
type APIGuild,
|
||||
type GatewayGuild,
|
||||
@ -10,7 +9,6 @@ import { ObservableSet, action, computed, makeObservable, observable } from "mob
|
||||
import AppStore from "../AppStore";
|
||||
import GuildMemberListStore from "../GuildMemberListStore";
|
||||
import GuildMemberStore from "../GuildMemberStore";
|
||||
import Channel from "./Channel";
|
||||
|
||||
export default class Guild {
|
||||
private readonly app: AppStore;
|
||||
@ -150,42 +148,6 @@ export default class Guild {
|
||||
.sort((a, b) => (a.position ?? 0) - (b.position ?? 0));
|
||||
}
|
||||
|
||||
@computed
|
||||
get channelsSorted() {
|
||||
const channels = this.channels;
|
||||
const categoryChannels = channels.filter((channel) => channel.type === ChannelType.GuildCategory);
|
||||
const nonCatChannels = channels.filter((channel) => channel.type !== ChannelType.GuildCategory);
|
||||
|
||||
const categories: { id: Snowflake; parent: Channel; children: Channel[] }[] = [];
|
||||
const uncategorized: Channel[] = [];
|
||||
|
||||
for (const channel of categoryChannels) {
|
||||
categories.push({
|
||||
id: channel.id,
|
||||
parent: channel,
|
||||
children: [],
|
||||
});
|
||||
}
|
||||
|
||||
for (const channel of nonCatChannels) {
|
||||
if (channel.parentId) {
|
||||
const category = categories.find((category) => category.id === channel.parentId);
|
||||
if (category) {
|
||||
category.children.push(channel);
|
||||
}
|
||||
} else {
|
||||
uncategorized.push(channel);
|
||||
}
|
||||
}
|
||||
|
||||
const a = categories.map((x) => {
|
||||
// return an array of parent, and children flattened
|
||||
return [x.parent, ...x.children.sort((a, b) => (a.position ?? 0) - (b.position ?? 0))];
|
||||
});
|
||||
|
||||
return [...a.flat(), ...uncategorized.sort((a, b) => (a.position ?? 0) - (b.position ?? 0))];
|
||||
}
|
||||
|
||||
@computed
|
||||
get roles() {
|
||||
return this.app.roles.getAll().filter((role) => this.roles_.has(role.id));
|
||||
|
Loading…
Reference in New Issue
Block a user