Skip to content

Commit 6ee926c

Browse files
committed
update has peers logic
1 parent 0573876 commit 6ee926c

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

web/src/hooks/useProjectStatusInfos.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ const getNewInfos = async (
2525
const networkInfos = agentPubKey
2626
? await appWs.dumpNetworkMetrics({ include_dht_summary: false })
2727
: undefined
28+
console.log('getNewInfos:', {
29+
appInfo: appInfo.cell_info['projects'],
30+
status: appInfo.status,
31+
})
2832
const clonedProjectCells: ClonedCell[] = appInfo.cell_info['projects']
2933
.filter(
3034
(cellInfo) => CellType.Cloned === cellInfo.type && cellInfo.value.enabled
@@ -50,7 +54,8 @@ const getNewInfos = async (
5054
if (networkInfo) {
5155
// 1 means 'only me'
5256
// 2 or more means currently active peers
53-
hasPeers = networkInfo.local_agents.length > 1
57+
hasPeers =
58+
Object.keys(networkInfo.gossip_state_summary.dht_summary).length > 1
5459
isGossiping =
5560
Object.values(networkInfo.fetch_state_summary.pending_requests).flat
5661
.length > 0
@@ -87,7 +92,7 @@ export default function usePendingProjects(
8792
const check = async () => {
8893
try {
8994
if (!isMounted) return
90-
95+
9196
const withHasProjectMetas = await Promise.all(
9297
projectCellIdStrings.map(async (projectCellId) => {
9398
try {
@@ -112,14 +117,14 @@ export default function usePendingProjects(
112117
}
113118
})
114119
)
115-
120+
116121
if (!isMounted) return
117-
122+
118123
// mix in the the network infos for all projects
119124
const newInfos = await getNewInfos(withHasProjectMetas)
120-
125+
121126
if (!isMounted) return
122-
127+
123128
// return a result
124129
setProjectStatusInfos(newInfos)
125130
} catch (e) {

0 commit comments

Comments
 (0)