mirror of https://github.com/sualko/cloud_bbb
fix: show room loading error
parent
7192077919
commit
bee124d19f
|
@ -36,6 +36,7 @@ type Props = {
|
||||||
|
|
||||||
const App: React.FC<Props> = () => {
|
const App: React.FC<Props> = () => {
|
||||||
const [areRoomsLoaded, setRoomsLoaded] = useState(false);
|
const [areRoomsLoaded, setRoomsLoaded] = useState(false);
|
||||||
|
const [error, setError] = useState<string>('');
|
||||||
const [rooms, setRooms] = useState<Room[]>([]);
|
const [rooms, setRooms] = useState<Room[]>([]);
|
||||||
const [orderBy, setOrderBy] = useState<SortKey>('name');
|
const [orderBy, setOrderBy] = useState<SortKey>('name');
|
||||||
const [sortOrder, setSortOrder] = useState(SortOrder.ASC);
|
const [sortOrder, setSortOrder] = useState(SortOrder.ASC);
|
||||||
|
@ -48,8 +49,13 @@ const App: React.FC<Props> = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
api.getRooms().then(rooms => {
|
api.getRooms().then(rooms => {
|
||||||
setRoomsLoaded(true);
|
|
||||||
setRooms(rooms);
|
setRooms(rooms);
|
||||||
|
}).catch((err) => {
|
||||||
|
console.warn('Could not load rooms', err);
|
||||||
|
|
||||||
|
setError(t('bbb', 'Server error'));
|
||||||
|
}).then(() => {
|
||||||
|
setRoomsLoaded(true);
|
||||||
});
|
});
|
||||||
}, [areRoomsLoaded]);
|
}, [areRoomsLoaded]);
|
||||||
|
|
||||||
|
@ -120,6 +126,7 @@ const App: React.FC<Props> = () => {
|
||||||
<tfoot>
|
<tfoot>
|
||||||
<tr>
|
<tr>
|
||||||
<td colSpan={3}>
|
<td colSpan={3}>
|
||||||
|
{error && <><span className="icon icon-error icon-visible"></span> {error}</>}
|
||||||
{!areRoomsLoaded && <span className="icon icon-loading-small icon-visible"></span>}
|
{!areRoomsLoaded && <span className="icon icon-loading-small icon-visible"></span>}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
|
Loading…
Reference in New Issue