From eb962bd8041bf2aadbe57b6e32a46d206ec50864 Mon Sep 17 00:00:00 2001 From: Puyodead1 Date: Thu, 1 Jun 2023 10:52:55 -0400 Subject: [PATCH] prevent navigating to non-text channels --- src/components/ChannelList.tsx | 7 ++++++- src/stores/objects/Channel.ts | 18 +++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/components/ChannelList.tsx b/src/components/ChannelList.tsx index 0add4c9..0c569b5 100644 --- a/src/components/ChannelList.tsx +++ b/src/components/ChannelList.tsx @@ -67,7 +67,12 @@ function ChannelList() { key={channel.id} isCategory={isCategory} onClick={() => - navigate(`/channels/${guild.id}/${channel.id}`) + { + // prevent navigating to non-text channels + if (!channel.isTextChannel) return; + + navigate(`/channels/${guild.id}/${channel.id}`) + } } > diff --git a/src/stores/objects/Channel.ts b/src/stores/objects/Channel.ts index 9749d5b..6bf966f 100644 --- a/src/stores/objects/Channel.ts +++ b/src/stores/objects/Channel.ts @@ -14,7 +14,7 @@ import type { Snowflake as SnowflakeType, } from "@spacebarchat/spacebar-api-types/v9"; import { ChannelType, Routes } from "@spacebarchat/spacebar-api-types/v9"; -import { action, makeObservable, observable } from "mobx"; +import { action, computed, makeObservable, observable } from "mobx"; import AppStore from "../AppStore"; import MessageStore from "../MessageStore"; import { APIError } from "../../utils/interfaces/api"; @@ -208,4 +208,20 @@ export default class Channel { return true; } + + @computed + get isTextChannel() { + return ( + this.type === ChannelType.GuildText || + this.type === ChannelType.GuildStore || + this.type === ChannelType.GuildForum || + this.type === ChannelType.AnnouncementThread || + this.type === ChannelType.Encrypted || + this.type === ChannelType.EncryptedThread || + this.type === ChannelType.PrivateThread || + this.type === ChannelType.PublicThread || + this.type === ChannelType.GroupDM || + this.type === ChannelType.DM + ); + } }