Skip to content

Commit

Permalink
fix private categories not showing public children
Browse files Browse the repository at this point in the history
  • Loading branch information
Puyodead1 committed Dec 19, 2023
1 parent f720ce8 commit 45ae20e
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/stores/objects/Guild.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { Snowflake } from "@spacebarchat/spacebar-api-types/globals";
import {
ChannelType,
RESTPutAPIGuildBanJSONBody,
RESTPutAPIGuildBanResult,
Routes,
Expand Down Expand Up @@ -146,9 +147,17 @@ export default class Guild {

@computed
get channels() {
const guildChannels = this.app.channels.all.filter(
(channel) => this.channels_.has(channel.id) && channel.hasPermission("VIEW_CHANNEL"),
);
let guildChannels = this.app.channels.all.filter((channel) => this.channels_.has(channel.id));
guildChannels = guildChannels.filter((channel) => {
if (channel.type === ChannelType.GuildCategory) {
// check if any children are visible
return guildChannels.some(
(child) => child.parentId === channel.id && child.hasPermission("VIEW_CHANNEL"),
);
}

return channel.hasPermission("VIEW_CHANNEL");
});
const topLevelChannels = guildChannels.filter((channel) => !channel.parentId);
const sortedChannels = topLevelChannels
.sort(compareChannels)
Expand Down

0 comments on commit 45ae20e

Please sign in to comment.