Skip to content

Commit

Permalink
refactor data
Browse files Browse the repository at this point in the history
  • Loading branch information
Nurudeen38 committed Nov 19, 2022
1 parent 58e9dfa commit 95e95d7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
5 changes: 2 additions & 3 deletions web/src/hooks/useSocket.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ export default function useSocket(options = {}) {
(group: any, server: any) => {
const { Message } = server;
const { Name,Host } = Message;
group[Name] = group[Name] ?? [];
group[Name].host = Host;
group[Name].push(server);
group[Name] = group[Name] ?? { data: [], Host };
group[Name].data.push(server);
return group;
},
{}
Expand Down
4 changes: 2 additions & 2 deletions web/src/server/ServerDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export default function ServerDetail({
{Object.keys(servicesGroupedByName)
?.sort()
?.map((serverName: string, index: number) => {
if (host !== servicesGroupedByName[serverName].host) return null;
if (host !== servicesGroupedByName[serverName].Host) return null;

return (
<div key={index}>
Expand All @@ -71,7 +71,7 @@ export default function ServerDetail({
serverData={
servicesGroupedByName[
serverName as ServerServiceNameType
]?.at(-1) as ServerResponseType
]?.data?.at(-1) as ServerResponseType
} // get the last object of service
/>
)}
Expand Down
6 changes: 5 additions & 1 deletion web/src/server/ServerType.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,9 @@ export interface ServerGroupedByHostResponseType {
}

export interface ServerGroupedByNameResponseType {
[Name: string]: ServerResponseType[];
[Name: string]: {
data:ServerResponseType[];
Host:string;
}

}

0 comments on commit 95e95d7

Please sign in to comment.