1
0
mirror of https://github.com/spacebarchat/client.git synced 2024-11-25 19:52:31 +01:00

prevent navigating to non-text channels

This commit is contained in:
Puyodead1 2023-06-01 10:52:55 -04:00
parent dd81402647
commit eb962bd804
No known key found for this signature in database
GPG Key ID: BA5F91AAEF68E5CE
2 changed files with 23 additions and 2 deletions

View File

@ -67,8 +67,13 @@ function ChannelList() {
key={channel.id}
isCategory={isCategory}
onClick={() =>
{
// prevent navigating to non-text channels
if (!channel.isTextChannel) return;
navigate(`/channels/${guild.id}/${channel.id}`)
}
}
>
<FirstWrapper isCategory={isCategory} active={active}>
{channel.channelIcon && (

View File

@ -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
);
}
}