fedwiki / wiki-client

Federated wiki client-side javascript as a npm module.
Other
117 stars 38 forks source link

ignore any sites with sitemap request still inflight when counting pages #289

Closed paul90 closed 2 years ago

paul90 commented 2 years ago

The total number of pages gets recalculated triggered by the new-neighbor-done event. However, some neighbors might not be done yet so those will fail with a type error when trying to count the number of pages with site.sitemap.length.

In this change any site that are still in flight, sitemapRequestInflight is still true, are ignored. They will eventually get included as they complete and fire their own new-neighbor-done event.

paul90 commented 2 years ago

I spotted this problem both when loading a page that added more than one site to the neighbourhood, and refreshing the browser when the neighbourhood had 2 or more sites.

I think the catch is going to be needed if there is something very wrong with a site. The sitemapRequestInflight event is fired, and sitemapRequestInflight unset, when a sitemap has loaded. So, by ignoring sites where the request hasn't completed there should be a something in the sitemap, and the catch will only happen when it doesn't have a length.

WardCunningham commented 2 years ago

Ah. A condition that I hadn't considered. Thanks for explaining this. I'm happy to see it merged.

paul90 commented 2 years ago

published as + wiki-client@0.23.5