Skip to content

Commit

Permalink
fix: regression where ShowHiddenChannels errors when `isHiddenChannel…
Browse files Browse the repository at this point in the history
…` is called with an object that is not a `ChannelRecord`
  • Loading branch information
ryan-0324 committed Jun 30, 2024
1 parent 450efac commit 366da53
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/plugins/showHiddenChannels/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { canonicalizeMatch } from "@utils/patches";
import definePlugin, { OptionType, type Patch } from "@utils/types";
import type { ChannelRecord, GuildCategoryChannelRecord, GuildChannel, GuildChannelRecord, Role } from "@vencord/discord-types";
import { findByPropsLazy } from "@webpack";
import { Permissions, PermissionStore, Tooltip } from "@webpack/common";
import { ChannelStore, Permissions, PermissionStore, Tooltip } from "@webpack/common";

import HiddenChannelLockScreen from "./components/HiddenChannelLockScreen";

Expand Down Expand Up @@ -476,8 +476,13 @@ export default definePlugin({
}
],

isHiddenChannel(channel?: ChannelRecord, checkConnect = false) {
if (!channel || channel.isPrivate()) return false;
isHiddenChannel(channel?: ChannelRecord | { channelId: string; }, checkConnect = false) {
if (!channel) return false;

if (!("isPrivate" in channel)) {
channel = ChannelStore.getChannel(channel.channelId);
if (!channel || !channel.isPrivate()) return false;
}

return !PermissionStore.can(Permissions.VIEW_CHANNEL, channel)
|| checkConnect && !PermissionStore.can(Permissions.CONNECT, channel);
Expand Down

0 comments on commit 366da53

Please sign in to comment.