Created
May 29, 2023 20:24
-
-
Save jasonLaster/470b51827f4cffc8b41b4d61fcd2f70a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/hooks/useCategorizeFilters.ts b/src/hooks/useCategorizeFilters.ts | |
index 31d9740..8011ebe 100644 | |
--- a/src/hooks/useCategorizeFilters.ts | |
+++ b/src/hooks/useCategorizeFilters.ts | |
@@ -60,10 +60,10 @@ export function useCategorizeFilters( | |
const allReportIds = getIds(allReports); | |
// 1. Compute deltas | |
- const changedFilterIds = difference(allFilterIds, oldData.filterIds); | |
- const removedFilterIds = difference(oldData.filterIds, allFilterIds); | |
- const changedReportIds = difference(allReportIds, oldData.reportIds); | |
- const removedReportIds = difference(oldData.reportIds, allReportIds); | |
+ const changedFilterIds = difference(allFilterIds, oldData?.filterIds); | |
+ const removedFilterIds = difference(oldData?.filterIds, allFilterIds); | |
+ const changedReportIds = difference(allReportIds, oldData?.reportIds); | |
+ const removedReportIds = difference(oldData?.reportIds, allReportIds); | |
const hadAnyChanges = | |
changedFilterIds.length || | |
@@ -78,7 +78,7 @@ export function useCategorizeFilters( | |
const allReportsById = makeDBDictionary(allReports); | |
// 2a. Remove old hits by filters. | |
- const filterHitIds = { ...oldData.filterHits }; | |
+ const filterHitIds = { ...oldData?.filterHits }; | |
for (const filterId of removedFilterIds) { | |
delete filterHitIds[filterId]; | |
} | |
@@ -141,7 +141,14 @@ export function useCategorizeFilters( | |
console.log( | |
`[categorization] ${duration}s - ${changedReportIds.length} new crashes, ${changedFilterIds.length}/${removedFilterIds.length} new/removed filters` | |
); | |
- }, [allFilters, allReports, filterHits, filterFilter, reportsLoading, filtersLoading]); | |
+ }, [ | |
+ allFilters, | |
+ allReports, | |
+ filterHits, | |
+ filterFilter, | |
+ reportsLoading, | |
+ filtersLoading, | |
+ ]); | |
const getFilterHitCount = useCallback( | |
(filterId: number) => filterHits?.[filterId]?.length || 0, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment