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

This commit is contained in:
goat 2021-09-07 21:40:46 +02:00
parent 4787a2166f
commit 55a7b00954
No known key found for this signature in database
GPG key ID: 7773BB5B43BA52E5

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(() => {