Skip to content

Commit

Permalink
handle some corner cases
Browse files Browse the repository at this point in the history
  • Loading branch information
mirekys committed Mar 24, 2023
1 parent c971bc9 commit 53f2e39
Showing 1 changed file with 23 additions and 21 deletions.
44 changes: 23 additions & 21 deletions src/pages/_app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,29 @@ export default function App({ Component, pageProps = { title: 'index' } }) {
const randomProviderConnections = useMemo(
() =>
providers
.sort(() => 0.5 - Math.random())
.map((p1, i) =>
Math.random() > 0.5
? providers
.slice(i, Math.floor(Math.random() * 1000) % providers.length)
.map((p2) => (Math.random() > 0.5 ? [p1, p2] : [p1, p2]))
: [],
)
.flat()
.filter(([p1, p2]) => !areEqual(p1, p2) && p1.location && p2.location)
.map(([p1, p2]) => {
const { lat: startLat, lng: startLng } = p1.location
const { lat: endLat, lng: endLng } = p2.location
return {
startLat,
startLng,
endLat,
endLng,
color: '#c7e8f9',
}
}),
? providers
.sort(() => 0.5 - Math.random())
.map((p1, i) =>
Math.random() > 0.5
? providers
.slice(i, Math.floor(Math.random() * 1000) % providers.length)
.map((p2) => (Math.random() > 0.5 ? [p1, p2] : [p1, p2]))
: [],
)
.flat()
.filter(([p1, p2]) => !areEqual(p1, p2) && p1.location && p2.location)
.map(([p1, p2]) => {
const { lat: startLat, lng: startLng } = p1.location
const { lat: endLat, lng: endLng } = p2.location
return {
startLat,
startLng,
endLat,
endLng,
color: '#c7e8f9',
}
})
: {},
[providers],
)

Expand Down

0 comments on commit 53f2e39

Please sign in to comment.