Skip to content

Commit 8b2ff05

Browse files
committed
fix(stac): drop a request for items the user has since asked to leave
1 parent dd2b3b1 commit 8b2ff05

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

packages/plugins/src/plugins/maplibre-stac.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -886,10 +886,10 @@ function buildPanel(container: HTMLElement): () => void {
886886

887887
/** The tree asked for a collection: search it, and send the map to it. */
888888
function showCollection(href: string, bbox?: [number, number, number, number]): void {
889-
void runSearch(false);
890-
// The search this belongs to. Asking for a second collection while the first extent is still
891-
// in flight would otherwise send the map where the user no longer is.
892-
const generation = searchGeneration;
889+
// The search this belongs to, taken before it starts rather than read back afterwards: asking
890+
// for a second collection while the first extent is in flight must not move the map back.
891+
const generation = ++searchGeneration;
892+
void runSearch(false, generation);
893893
if (bbox) return void appRef?.fitBounds?.(bbox);
894894
// A collection guessed from its link has never been read, so its extent has to be fetched.
895895
void openCatalogNode(href, fetch, controller.signal)
@@ -899,9 +899,9 @@ function buildPanel(container: HTMLElement): () => void {
899899
.catch(() => undefined);
900900
}
901901

902-
async function runSearch(append: boolean): Promise<void> {
902+
async function runSearch(append: boolean, generation = ++searchGeneration): Promise<void> {
903903
if (!connection) return;
904-
const generation = ++searchGeneration;
904+
905905
searchButton.disabled = true;
906906
loadMore.disabled = true;
907907
setStatus(append ? labels.loadingMore : labels.searching);

0 commit comments

Comments
 (0)