aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2026-10-31 16:39:12 -0500
committerJP Dillingham <jp@dillingham.me>2026-10-31 16:39:12 -0500
commit09653f3781c5429a1a68916f062e56c03593a41f (patch)
tree8d709c0d9ab4def827e33feb945f17ec568d3f16
parent47c0c9fccbe976c1d1f8f71c6b0bfd45bceda1a4 (diff)
downloadslskd-09653f3781c5429a1a68916f062e56c03593a41f.tar.gz
defensive load of events
-rw-r--r--src/web/src/components/System/Events/index.jsx27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/web/src/components/System/Events/index.jsx b/src/web/src/components/System/Events/index.jsx
index 7f708908..b0549259 100644
--- a/src/web/src/components/System/Events/index.jsx
+++ b/src/web/src/components/System/Events/index.jsx
@@ -17,18 +17,27 @@ const Events = () => {
const fetch = async () => {
setLoading(true);
- const { events: items, totalCount } = await list({
- limit: PER_PAGE,
- offset: (page - 1) * PER_PAGE,
- });
+ try {
+ const { events: items, totalCount } = await list({
+ limit: PER_PAGE,
+ offset: (page - 1) * PER_PAGE,
+ });
- const tp = Math.ceil(totalCount / PER_PAGE);
+ const tp = Math.ceil(totalCount / PER_PAGE);
- setEvents(items);
- setTotalPages(Number.isNaN(tp) ? 0 : tp);
- setLoading(false);
+ setEvents(items);
+ setTotalPages(Number.isNaN(tp) ? 0 : tp);
- return items;
+ return items;
+ } catch (error) {
+ console.error(error);
+ setEvents([]);
+ setTotalPages(0);
+
+ return [];
+ } finally {
+ setLoading(false);
+ }
};
const paginationChanged = ({ activePage }) => {