Skip to content

Commit 0bef531

Browse files
authored
fix: handle empty staking information and ensure loading state is set correctly (#521)
1 parent a494a52 commit 0bef531

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

frontend/components/ManageStakingPage/StakingContractSection/StakingContractDetails.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export const StakingContractDetails = ({
5050
return <Skeleton active />;
5151
}
5252

53-
if (!stakingContractInfoRecord) {
53+
if (!stakingContractInfoRecord || !list || list.length === 0) {
5454
return (
5555
<Alert
5656
message="No staking information available."
@@ -61,6 +61,6 @@ export const StakingContractDetails = ({
6161
}
6262

6363
return (
64-
<InfoBreakdownList list={list!} parentStyle={{ gap: 12 }} color="primary" />
64+
<InfoBreakdownList list={list} parentStyle={{ gap: 12 }} color="primary" />
6565
);
6666
};

frontend/context/StakingContractInfoProvider.tsx

+5-3
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,11 @@ export const StakingContractInfoProvider = ({
7979
AutonolasService.getStakingContractInfoByServiceIdStakingProgram(
8080
serviceId,
8181
activeStakingProgramId,
82-
).then(setActiveStakingContractInfo);
83-
84-
setIsActiveStakingContractInfoLoaded(true);
82+
)
83+
.then(setActiveStakingContractInfo)
84+
.finally(() => {
85+
setIsActiveStakingContractInfoLoaded(true);
86+
});
8587
}, [activeStakingProgramId, serviceId]);
8688

8789
/** Updates general staking contract information, not user or service specific */

0 commit comments

Comments
 (0)