ayn2op / discordo

A lightweight, secure, and feature-rich Discord terminal client.
MIT License
1.91k stars 63 forks source link

Fix hidden category/channel bug #369

Closed cyberme0w closed 4 months ago

cyberme0w commented 4 months ago

Hi!

I saw #368 and decided to take a bit of a closer look at it. I set up a server like this, which I think emulates the situation described in the issue close enough:

Previously, this resulted in the following GuildTree:

With this fix, the GuildTree looks like this for the role1 member:

This matches how the web client displays them, too.

The issue was that categories were not being drawn if the user did not have view channel permissions for them. However, a category can be hidden and still have user-visible channels, which should be drawn in the guild tree.

With this fix, the createChannelNodes() function now has three steps as follows:

  1. Draw all top-level, non-category channels
  2. Draw categories that have at least one visible channel (regardless of the categories' own visibility)
  3. Draw channels inside (visible) categories if they are visible to the user

Cheers!

epetousis commented 4 months ago

Fix definitely works, thanks so much!