Skip to content

Commit 6732590

Browse files
committed
fix(#2683): handle missing usersnap api key exception
1 parent e1831a9 commit 6732590

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ changes.
7979
- Fix usage of trim on missing label
8080
- Fix blank screen when registering as a DRep [Issue 2408](https://github.com/IntersectMBO/govtool/issues/2408)
8181
- Fix type mismatch between sql and haskell code for stake key address
82+
- Handle missing api key exception [Issue 2683](https://github.com/IntersectMBO/govtool/issues/2683)
8283

8384
### Changed
8485

govtool/frontend/src/context/usersnapContext.tsx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,19 @@ export const UsersnapProvider = ({
7373
}, [usersnapApi]);
7474

7575
useEffect(() => {
76-
loadSpace(API_KEY).then((api) => {
77-
api.init(initParams);
78-
setUsersnapApi(api);
79-
});
80-
}, [initParams]);
76+
const initUsersnapSpace = async () => {
77+
if (API_KEY) {
78+
try {
79+
const api = await loadSpace(API_KEY);
80+
api.init(initParams);
81+
setUsersnapApi(api);
82+
} catch (error) {
83+
console.error(error);
84+
}
85+
}
86+
};
87+
initUsersnapSpace();
88+
}, [initParams, API_KEY]);
8189

8290
const value = useMemo(() => ({ openFeedbackWindow }), [openFeedbackWindow]);
8391

0 commit comments

Comments
 (0)