Skip to content

Commit

Permalink
fix: catch thrown error as middleware errors during deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
truemiller committed Nov 6, 2024
1 parent 40d72aa commit 8382f35
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions frontend/hooks/useServices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,20 @@ export const useServices = () => {
hasInitialLoaded ? services : [];

const updateServiceState = (serviceHash: ServiceHash) => {
ServicesService.getService(serviceHash).then((service: Service) => {
setServices((prev) => {
if (!prev) return [service];

const index = prev.findIndex((s) => s.hash === serviceHash); // findIndex returns -1 if not found
if (index === -1) return [...prev, service];

const newServices = [...prev];
newServices[index] = service;
return newServices;
});
});
ServicesService.getService(serviceHash)
.then((service: Service) => {
setServices((prev) => {
if (!prev) return [service];

const index = prev.findIndex((s) => s.hash === serviceHash); // findIndex returns -1 if not found
if (index === -1) return [...prev, service];

const newServices = [...prev];
newServices[index] = service;
return newServices;
});
})
.catch(console.error);
};

const deleteServiceState = (serviceHash: ServiceHash) =>
Expand Down

0 comments on commit 8382f35

Please sign in to comment.