From afa228fd6d2d880230c219fcb419a64278544f00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20=C5=BBegle=C5=84?= Date: Thu, 18 Feb 2021 14:05:39 +0100 Subject: [PATCH] Fix no channels crash (#984) * Fix crash caused by not having any channels * Update changelog --- CHANGELOG.md | 1 + src/components/AppLayout/AppChannelContext.tsx | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 88c8d972c..ce95e8597 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ All notable, unreleased changes to this project will be documented in this file. - Drop descriptionJson and contentJson fields - #950 by @jwm0 - Add error tracking with Sentry adapter - #956 by @jwm0 - Add OAuth2 login with OpenID support - #963 by @orzechdev +- Fix no channels crash - #984 by @dominik-zeglen # 2.11.1 diff --git a/src/components/AppLayout/AppChannelContext.tsx b/src/components/AppLayout/AppChannelContext.tsx index 3b479efe7..cf2a16d49 100644 --- a/src/components/AppLayout/AppChannelContext.tsx +++ b/src/components/AppLayout/AppChannelContext.tsx @@ -33,7 +33,7 @@ export const AppChannelProvider: React.FC = ({ children }) => { const [isPickerActive, setPickerActive] = React.useState(false); React.useEffect(() => { - if (!selectedChannel && channelData?.channels) { + if (!selectedChannel && channelData?.channels?.length > 0) { setSelectedChannel(channelData.channels[0].id); } }, [channelData]);