From bee124d19f028a92ffb539245c3f8b60fdbe864e Mon Sep 17 00:00:00 2001 From: sualko Date: Wed, 17 Jun 2020 10:52:15 +0200 Subject: [PATCH] fix: show room loading error --- ts/Manager/App.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ts/Manager/App.tsx b/ts/Manager/App.tsx index da75e07..ae7ea1f 100644 --- a/ts/Manager/App.tsx +++ b/ts/Manager/App.tsx @@ -36,6 +36,7 @@ type Props = { const App: React.FC = () => { const [areRoomsLoaded, setRoomsLoaded] = useState(false); + const [error, setError] = useState(''); const [rooms, setRooms] = useState([]); const [orderBy, setOrderBy] = useState('name'); const [sortOrder, setSortOrder] = useState(SortOrder.ASC); @@ -48,8 +49,13 @@ const App: React.FC = () => { } api.getRooms().then(rooms => { - setRoomsLoaded(true); setRooms(rooms); + }).catch((err) => { + console.warn('Could not load rooms', err); + + setError(t('bbb', 'Server error')); + }).then(() => { + setRoomsLoaded(true); }); }, [areRoomsLoaded]); @@ -120,6 +126,7 @@ const App: React.FC = () => { + {error && <> {error}} {!areRoomsLoaded && }