Skip to content

Commit

Permalink
Awaiting county map load if already zooming
Browse files Browse the repository at this point in the history
  • Loading branch information
jacksonjude committed Dec 3, 2024
1 parent e764b7a commit 9fd8b16
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/model/map-source.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class MapSource
}
self.mapDates.sort((mapDate1, mapDate2) => (mapDate1-mapDate2))

let filterMapDataCallback = self.executeFilter(self.rawMapData, self.mapDates, self)
let filterMapDataCallback = await self.executeFilter(self.rawMapData, self.mapDates, self)
self.mapData = filterMapDataCallback.mapData

if (filterMapDataCallback.candidateNameData != null && resetCandidateNames)
Expand Down Expand Up @@ -154,9 +154,9 @@ class MapSource
return true
}

executeFilter(rawData, mapDates, self = this, ...args)
async executeFilter(rawData, mapDates, self = this, ...args)
{
return self.filterMapDataFunction(rawData, mapDates, self.columnMap, self.cycleYear, self.candidateNameToPartyIDMap, self.regionNameToIDMap, self.heldRegionMap, self.shouldFilterOutDuplicateRows, self.isCustomMap, self.voteshareCutoffMargin, !self.isCustomMap || self.editingMode == EditingMode.voteshare, ...args)
return await self.filterMapDataFunction(rawData, mapDates, self.columnMap, self.cycleYear, self.candidateNameToPartyIDMap, self.regionNameToIDMap, self.heldRegionMap, self.shouldFilterOutDuplicateRows, self.isCustomMap, self.voteshareCutoffMargin, !self.isCustomMap || self.editingMode == EditingMode.voteshare, ...args)
}

async loadMapCache(self, reloadCache, onlyAttemptLocalFetch)
Expand Down
11 changes: 8 additions & 3 deletions src/model/map-types/usa-president-map-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -1255,7 +1255,7 @@ var USAPresidentMapType = new MapType(

removeLoader(LoaderType.standard)

const { mapData } = CNNResults2024MapSource.executeFilter(countyZoomData, [date], undefined, true)
const { mapData } = await CNNResults2024MapSource.executeFilter(countyZoomData, [date], undefined, true)
let countyDateData = Object.values(mapData)[0]

if (countyToCityMap[zoomRegion])
Expand Down Expand Up @@ -1811,8 +1811,13 @@ var USAPresidentMapType = new MapType(
null, // heldRegionMap
false, // shouldFilterOutDuplicateRows
true, // addDecimalPadding
(rawMapData, mapDates, columnMap, _, candidateNameToPartyIDMap, regionNameToID, __, ___, isCustomMap, voteshareCutoffMargin, shouldIncludeVoteshare) => {
CountyElectionResultMapSource.loadMap()
async (rawMapData, mapDates, columnMap, _, candidateNameToPartyIDMap, regionNameToID, __, ___, isCustomMap, voteshareCutoffMargin, shouldIncludeVoteshare) => {
if (currentViewingState == ViewingState.zooming) {
await CountyElectionResultMapSource.loadMap()
} else {
CountyElectionResultMapSource.loadMap()
}

return doubleLineVoteshareFilterFunction(rawMapData, mapDates, columnMap, _, candidateNameToPartyIDMap, regionNameToID, __, ___, isCustomMap, voteshareCutoffMargin, shouldIncludeVoteshare)
}, // organizeMapDataFunction
null, // viewingDataFunction
Expand Down

0 comments on commit 9fd8b16

Please sign in to comment.