Skip to content

Commit

Permalink
refactor: optimize useServicesLogs for better readability and perform…
Browse files Browse the repository at this point in the history
…ance
  • Loading branch information
mohandast52 committed Dec 19, 2024
1 parent d28fc6a commit 16049f8
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions frontend/hooks/useLogs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,21 +85,23 @@ const useServicesLogs = () => {
const { services, isFetched: isLoaded, selectedService } = useServices();

const formattedServices = useMemo(() => {
return (
services?.map((item: Service) => ({
return services?.map((item: Service) => {
const isSameService =
selectedService?.service_config_id === item.service_config_id;

return {
...item,
keys: item.keys.map((key) => key.address),
deploymentStatus:
selectedService?.service_config_id === item.service_config_id
? selectedService.deploymentStatus
: item.deploymentStatus,
})) ?? 'undefined'
);
deploymentStatus: isSameService
? selectedService.deploymentStatus
: item.deploymentStatus,
};
});
}, [services, selectedService]);

return {
isLoaded,
data: { services: formattedServices },
data: { services: formattedServices ?? 'undefined' },
};
};

Expand Down Expand Up @@ -129,9 +131,3 @@ export const useLogs = () => {

return logs;
};

/**
* - type of agent,
* - when was it last staked,
* - how long until it can be unstaked (we already have this),
*/

0 comments on commit 16049f8

Please sign in to comment.