Commit 6e486bc1 authored by BrittainJackson7's avatar BrittainJackson7
Browse files

Fix Fetcher Bug

Fixes #11
parent 48322ece
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -203,7 +203,9 @@ export default function FootprintResults(props) {
  for(const key in featureCollections){
    if(featureCollections[key].numberReturned > 0) noFootprintsReturned = false;
  }

  if(numFeatures > matched) {
    setNumFeatures(matched);
  }
  return (
    <div id="footprintResults" className="scroll-parent">
      {hasFootprints &&
+22 −7
Original line number Diff line number Diff line
@@ -133,15 +133,30 @@ export async function FetchFootprints(collection, page, step){
}

export async function FetchStepRemainder(featureCollection, myStep) {
    if (!featureCollection || !featureCollection.features) {
        console.error('Invalid featureCollection:', featureCollection);
        return [];
    }

    let myPage = Math.ceil(featureCollection.features.length / myStep);
    let skip = featureCollection.features.length % myStep;
    let newFeatures = [];
    let fullResponse;

    if (skip !== 0) {
      newFeatures = await FetchFootprints(featureCollection, myPage, myStep);
        fullResponse = await FetchFootprints(featureCollection, myPage, myStep);

        if (!fullResponse || !fullResponse.features) {
            console.error('Invalid fullResponse:', fullResponse);
            return [];
        }

        newFeatures = fullResponse.features;

      // If any features are returned, add the remainder needed to the current collection
      if (newFeatures.length > 0) {
        // Handle edge case where you may have requested more features than  still available
        if (newFeatures.length < myStep) {
            return newFeatures;
        } else {
            return newFeatures.slice(skip, newFeatures.length);
        }
    }