fix: choose the first channel in the server if none is selected

pull/1049/head
goat 2021-09-07 21:40:46 +02:00
parent 7fc830eacf
commit bfccd9cfac
1 changed files with 4 additions and 0 deletions

View File

@ -62,7 +62,11 @@ const ServerSidebar = observer((props: Props) => {
if (!server) return <Redirect to="/" />;
const channel = channel_id ? client.channels.get(channel_id) : undefined;
// The user selected no channel, let's see if there's a channel available
if (!channel && server.channel_ids.length > 0) return <Redirect to={`/server/${server_id}/channel/${server.channel_ids[0]}`} />;
if (channel_id && !channel) return <Redirect to={`/server/${server_id}`} />;
if (channel) useUnreads({ ...props, channel });
useEffect(() => {