@internetarchive/collection-browser 1.14.17-alpha.4 → 1.14.17-alpha.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/dist/index.d.ts +3 -2
  2. package/dist/index.js +3 -2
  3. package/dist/index.js.map +1 -1
  4. package/dist/src/collection-browser.d.ts +6 -13
  5. package/dist/src/collection-browser.js +56 -30
  6. package/dist/src/collection-browser.js.map +1 -1
  7. package/dist/src/data-source/collection-browser-data-source-interface.d.ts +194 -0
  8. package/dist/src/data-source/collection-browser-data-source-interface.js +2 -0
  9. package/dist/src/data-source/collection-browser-data-source-interface.js.map +1 -0
  10. package/dist/src/data-source/collection-browser-data-source.d.ts +62 -174
  11. package/dist/src/data-source/collection-browser-data-source.js +185 -64
  12. package/dist/src/data-source/collection-browser-data-source.js.map +1 -1
  13. package/dist/src/data-source/collection-browser-query-state.d.ts +42 -0
  14. package/dist/src/data-source/collection-browser-query-state.js +2 -0
  15. package/dist/src/data-source/collection-browser-query-state.js.map +1 -0
  16. package/dist/src/data-source/models.d.ts +1 -39
  17. package/dist/src/data-source/models.js.map +1 -1
  18. package/dist/src/models.d.ts +3 -2
  19. package/dist/src/models.js +24 -22
  20. package/dist/src/models.js.map +1 -1
  21. package/dist/src/sort-filter-bar/sort-filter-bar.js +1 -0
  22. package/dist/src/sort-filter-bar/sort-filter-bar.js.map +1 -1
  23. package/dist/src/tiles/grid/item-tile.d.ts +1 -0
  24. package/dist/src/tiles/grid/item-tile.js +28 -1
  25. package/dist/src/tiles/grid/item-tile.js.map +1 -1
  26. package/dist/src/tiles/grid/tile-stats.js +13 -8
  27. package/dist/src/tiles/grid/tile-stats.js.map +1 -1
  28. package/dist/src/tiles/item-image.d.ts +3 -0
  29. package/dist/src/tiles/item-image.js +30 -2
  30. package/dist/src/tiles/item-image.js.map +1 -1
  31. package/dist/src/tiles/list/tile-list.d.ts +1 -0
  32. package/dist/src/tiles/list/tile-list.js +30 -1
  33. package/dist/src/tiles/list/tile-list.js.map +1 -1
  34. package/dist/src/tiles/tile-dispatcher.js +3 -2
  35. package/dist/src/tiles/tile-dispatcher.js.map +1 -1
  36. package/dist/src/tiles/tile-display-value-provider.d.ts +5 -1
  37. package/dist/src/tiles/tile-display-value-provider.js +15 -1
  38. package/dist/src/tiles/tile-display-value-provider.js.map +1 -1
  39. package/dist/test/collection-browser.test.js +2 -6
  40. package/dist/test/collection-browser.test.js.map +1 -1
  41. package/index.ts +3 -5
  42. package/package.json +2 -2
  43. package/src/collection-browser.ts +70 -49
  44. package/src/data-source/collection-browser-data-source-interface.ts +245 -0
  45. package/src/data-source/collection-browser-data-source.ts +237 -281
  46. package/src/data-source/collection-browser-query-state.ts +53 -0
  47. package/src/data-source/models.ts +0 -47
  48. package/src/models.ts +7 -3
  49. package/src/sort-filter-bar/sort-filter-bar.ts +1 -0
  50. package/src/tiles/grid/item-tile.ts +36 -1
  51. package/src/tiles/grid/tile-stats.ts +12 -7
  52. package/src/tiles/item-image.ts +28 -0
  53. package/src/tiles/list/tile-list.ts +37 -1
  54. package/src/tiles/tile-dispatcher.ts +2 -1
  55. package/src/tiles/tile-display-value-provider.ts +19 -1
  56. package/test/collection-browser.test.ts +2 -8
@@ -2,6 +2,7 @@ import { FilterConstraint, FilterMapBuilder, SearchType, } from '@internetarchiv
2
2
  import { prefixFilterAggregationKeys, TileModel, } from '../models';
3
3
  import { sha1 } from '../utils/sha1';
4
4
  export class CollectionBrowserDataSource {
5
+ // eslint-disable-next-line no-useless-constructor
5
6
  constructor(
6
7
  /** The host element to which this controller should attach listeners */
7
8
  host,
@@ -13,9 +14,18 @@ export class CollectionBrowserDataSource {
13
14
  this.offset = 0;
14
15
  this.numTileModels = 0;
15
16
  /**
16
- * Maps the full query key to the pages being fetched for that query
17
+ * A set of fetch IDs that are valid for the current query state
17
18
  */
18
- this.pageFetchesInProgress = {};
19
+ this.fetchesInProgress = new Set();
20
+ /**
21
+ * A record of the query key used for the last search.
22
+ * If this changes, we need to load new results.
23
+ */
24
+ this.previousQueryKey = '';
25
+ this.searchResultsLoading = false;
26
+ this.facetsLoading = false;
27
+ // TEMP for ease of debugging
28
+ this.id = Math.random();
19
29
  /**
20
30
  * @inheritdoc
21
31
  */
@@ -24,6 +34,10 @@ export class CollectionBrowserDataSource {
24
34
  * @inheritdoc
25
35
  */
26
36
  this.endOfDataReached = false;
37
+ /**
38
+ * @inheritdoc
39
+ */
40
+ this.queryInitialized = false;
27
41
  /**
28
42
  * @inheritdoc
29
43
  */
@@ -36,6 +50,12 @@ export class CollectionBrowserDataSource {
36
50
  * @inheritdoc
37
51
  */
38
52
  this.prefixFilterCountMap = {};
53
+ /**
54
+ * Internal property to store the private value backing the `initialSearchComplete` getter.
55
+ */
56
+ this._initialSearchCompletePromise = new Promise(res => {
57
+ this._initialSearchCompleteResolver = res;
58
+ });
39
59
  /**
40
60
  * @inheritdoc
41
61
  */
@@ -94,10 +114,55 @@ export class CollectionBrowserDataSource {
94
114
  // Swap in the new pages
95
115
  this.pages = newPages;
96
116
  this.numTileModels -= numChecked;
97
- this.host.requestUpdate();
98
- this.host.refreshVisibleResults();
117
+ this.requestHostUpdate();
118
+ this.refreshVisibleResults();
99
119
  };
100
- this.host.addController(this);
120
+ // Just setting some property values
121
+ }
122
+ /**
123
+ * @inheritdoc
124
+ */
125
+ get initialSearchComplete() {
126
+ return this._initialSearchCompletePromise;
127
+ }
128
+ hostConnected() {
129
+ console.log('hostConnected', this.id);
130
+ this.setSearchResultsLoading(this.searchResultsLoading);
131
+ this.setFacetsLoading(this.facetsLoading);
132
+ }
133
+ hostUpdate() {
134
+ console.log('hostUpdate', this.id, this.previousQueryKey, this.pageFetchQueryKey);
135
+ // This reactive controller hook is run whenever the host component (collection-browser) performs an update.
136
+ // We check whether the host's state has changed in a way which should trigger a reset & new results fetch.
137
+ // Only the currently-installed data source should react to the update
138
+ if (!this.activeOnHost)
139
+ return;
140
+ // Copy loading states onto the host
141
+ this.setSearchResultsLoading(this.searchResultsLoading);
142
+ this.setFacetsLoading(this.facetsLoading);
143
+ // Can't perform searches without a search service
144
+ if (!this.host.searchService)
145
+ return;
146
+ // We should only reset if part of the full query state has changed
147
+ const queryKeyChanged = this.pageFetchQueryKey !== this.previousQueryKey;
148
+ console.log('query keys', this.pageFetchQueryKey, this.previousQueryKey);
149
+ if (!queryKeyChanged)
150
+ return;
151
+ // We should only reset if either:
152
+ // (a) our state permits a valid search, or
153
+ // (b) we have a blank query that we want to show empty results for
154
+ const shouldShowEmptyQueryResults = this.host.clearResultsOnEmptyQuery && this.host.baseQuery === '';
155
+ if (!(this.canPerformSearch || shouldShowEmptyQueryResults))
156
+ return;
157
+ if (this.activeOnHost)
158
+ this.host.emitQueryStateChanged();
159
+ this.handleQueryChange();
160
+ }
161
+ /**
162
+ * Returns whether this data source is the one currently installed on the host component.
163
+ */
164
+ get activeOnHost() {
165
+ return this.host.dataSource === this;
101
166
  }
102
167
  /**
103
168
  * @inheritdoc
@@ -109,18 +174,25 @@ export class CollectionBrowserDataSource {
109
174
  * @inheritdoc
110
175
  */
111
176
  reset() {
177
+ console.log('resetting data source', this.id);
112
178
  this.pages = {};
113
179
  this.aggregations = {};
114
180
  this.yearHistogramAggregation = undefined;
115
- this.pageFetchesInProgress = {};
116
181
  this.pageElements = undefined;
117
182
  this.parentCollections = [];
118
183
  this.prefixFilterCountMap = {};
184
+ this.queryErrorMessage = undefined;
119
185
  this.offset = 0;
120
186
  this.numTileModels = 0;
121
187
  this.totalResults = 0;
122
188
  this.endOfDataReached = false;
123
- this.host.requestUpdate();
189
+ this.queryInitialized = false;
190
+ // Invalidate any fetches in progress
191
+ this.fetchesInProgress.clear();
192
+ console.log('fetches cleared - size =', this.fetchesInProgress.size);
193
+ if (this.activeOnHost)
194
+ this.host.setTotalResultCount(0);
195
+ this.requestHostUpdate();
124
196
  }
125
197
  /**
126
198
  * @inheritdoc
@@ -128,7 +200,7 @@ export class CollectionBrowserDataSource {
128
200
  addPage(pageNum, pageTiles) {
129
201
  this.pages[pageNum] = pageTiles;
130
202
  this.numTileModels += pageTiles.length;
131
- this.host.requestUpdate();
203
+ this.requestHostUpdate();
132
204
  }
133
205
  /**
134
206
  * @inheritdoc
@@ -175,10 +247,18 @@ export class CollectionBrowserDataSource {
175
247
  */
176
248
  async handleQueryChange() {
177
249
  this.reset();
250
+ // Reset the `initialSearchComplete` promise with a new value for the imminent search
251
+ this._initialSearchCompletePromise = new Promise(res => {
252
+ this._initialSearchCompleteResolver = res;
253
+ });
254
+ // Fire the initial page & facet requests
255
+ this.queryInitialized = true;
178
256
  await Promise.all([
179
257
  this.doInitialPageFetch(),
180
258
  this.host.suppressFacets ? null : this.fetchFacets(),
181
259
  ]);
260
+ // Resolve the `initialSearchComplete` promise for this search
261
+ this._initialSearchCompleteResolver(true);
182
262
  }
183
263
  /**
184
264
  * @inheritdoc
@@ -188,8 +268,8 @@ export class CollectionBrowserDataSource {
188
268
  page,
189
269
  tileModels.map((model, index, array) => model ? callback(model, index, array) : model),
190
270
  ]));
191
- this.host.requestUpdate();
192
- this.host.refreshVisibleResults();
271
+ this.requestHostUpdate();
272
+ this.refreshVisibleResults();
193
273
  }
194
274
  /**
195
275
  * @inheritdoc
@@ -215,7 +295,6 @@ export class CollectionBrowserDataSource {
215
295
  .flat()
216
296
  .filter((model, index, array) => model ? predicate(model, index, array) : false);
217
297
  }
218
- // DATA FETCHES
219
298
  /**
220
299
  * @inheritdoc
221
300
  */
@@ -235,6 +314,43 @@ export class CollectionBrowserDataSource {
235
314
  (isCollectionSearch && isMetadataSearch) ||
236
315
  (isProfileSearch && hasProfileElement && isMetadataSearch));
237
316
  }
317
+ /**
318
+ * Sets the state for whether the initial set of search results for the
319
+ * current query is loading
320
+ */
321
+ setSearchResultsLoading(loading) {
322
+ this.searchResultsLoading = loading;
323
+ if (this.activeOnHost) {
324
+ this.host.setSearchResultsLoading(loading);
325
+ }
326
+ }
327
+ /**
328
+ * Sets the state for whether the facets for a query is loading
329
+ */
330
+ setFacetsLoading(loading) {
331
+ this.facetsLoading = loading;
332
+ if (this.activeOnHost) {
333
+ this.host.setFacetsLoading(loading);
334
+ }
335
+ }
336
+ /**
337
+ * Requests that the host perform an update, provided this data
338
+ * source is actively installed on it.
339
+ */
340
+ requestHostUpdate() {
341
+ if (this.activeOnHost) {
342
+ this.host.requestUpdate();
343
+ }
344
+ }
345
+ /**
346
+ * Requests that the host refresh its visible tiles, provided this
347
+ * data source is actively installed on it.
348
+ */
349
+ refreshVisibleResults() {
350
+ if (this.activeOnHost) {
351
+ this.host.refreshVisibleResults();
352
+ }
353
+ }
238
354
  /**
239
355
  * The query key is a string that uniquely identifies the current search.
240
356
  * It consists of:
@@ -246,16 +362,16 @@ export class CollectionBrowserDataSource {
246
362
  * - Any currently-applied prefix filters
247
363
  * - The current sort options
248
364
  *
249
- * This lets us keep track of queries so we don't persist data that's
250
- * no longer relevant.
365
+ * This lets us internally keep track of queries so we don't persist data that's
366
+ * no longer relevant. Not meant to be human-readable.
251
367
  */
252
368
  get pageFetchQueryKey() {
253
369
  var _a, _b, _c, _d, _e;
254
- const profileKey = `${this.host.withinProfile}--${this.host.profileElement}`;
370
+ const profileKey = `pf;${this.host.withinProfile}--pe;${this.host.profileElement}`;
255
371
  const pageTarget = (_a = this.host.withinCollection) !== null && _a !== void 0 ? _a : profileKey;
256
372
  const sortField = (_c = (_b = this.host.sortParam) === null || _b === void 0 ? void 0 : _b.field) !== null && _c !== void 0 ? _c : 'none';
257
373
  const sortDirection = (_e = (_d = this.host.sortParam) === null || _d === void 0 ? void 0 : _d.direction) !== null && _e !== void 0 ? _e : 'none';
258
- return `${this.fullQuery}-${pageTarget}-${this.host.searchType}-${sortField}-${sortDirection}`;
374
+ return `fq:${this.fullQuery}-pt:${pageTarget}-st:${this.host.searchType}-sf:${sortField}-sd:${sortDirection}`;
259
375
  }
260
376
  /**
261
377
  * Similar to `pageFetchQueryKey` above, but excludes sort fields since they
@@ -477,10 +593,15 @@ export class CollectionBrowserDataSource {
477
593
  */
478
594
  async fetchFacets() {
479
595
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
596
+ console.log('fetchFacets', this.id, this.host.profileElement);
480
597
  const trimmedQuery = (_a = this.host.baseQuery) === null || _a === void 0 ? void 0 : _a.trim();
481
598
  if (!this.canPerformSearch)
482
599
  return;
600
+ console.log('will actually fetch facets');
483
601
  const { facetFetchQueryKey } = this;
602
+ if (this.fetchesInProgress.has(facetFetchQueryKey))
603
+ return;
604
+ this.fetchesInProgress.add(facetFetchQueryKey);
484
605
  const sortParams = this.host.sortParam ? [this.host.sortParam] : [];
485
606
  const params = {
486
607
  ...this.pageSpecifierParams,
@@ -493,15 +614,18 @@ export class CollectionBrowserDataSource {
493
614
  // The default aggregations for the search_results page type should be what we need here.
494
615
  };
495
616
  params.uid = await this.requestUID({ ...params, sort: sortParams }, 'aggregations');
496
- this.host.setFacetsLoading(true);
617
+ this.setFacetsLoading(true);
497
618
  const searchResponse = await ((_b = this.host.searchService) === null || _b === void 0 ? void 0 : _b.search(params, this.host.searchType));
498
619
  const success = searchResponse === null || searchResponse === void 0 ? void 0 : searchResponse.success;
499
620
  // This is checking to see if the query has changed since the data was fetched.
500
621
  // If so, we just want to discard this set of aggregations because they are
501
622
  // likely no longer valid for the newer query.
502
- const queryChangedSinceFetch = facetFetchQueryKey !== this.facetFetchQueryKey;
503
- if (queryChangedSinceFetch)
623
+ const queryChangedSinceFetch = this.fetchesInProgress.has(facetFetchQueryKey);
624
+ this.fetchesInProgress.delete(facetFetchQueryKey);
625
+ if (queryChangedSinceFetch) {
626
+ console.log('facet query has changed since fetch, returning. new/old:', this.facetFetchQueryKey, facetFetchQueryKey);
504
627
  return;
628
+ }
505
629
  if (!success) {
506
630
  const errorMsg = (_c = searchResponse === null || searchResponse === void 0 ? void 0 : searchResponse.error) === null || _c === void 0 ? void 0 : _c.message;
507
631
  const detailMsg = (_e = (_d = searchResponse === null || searchResponse === void 0 ? void 0 : searchResponse.error) === null || _d === void 0 ? void 0 : _d.details) === null || _e === void 0 ? void 0 : _e.message;
@@ -509,6 +633,7 @@ export class CollectionBrowserDataSource {
509
633
  // @ts-ignore: Property 'Sentry' does not exist on type 'Window & typeof globalThis'
510
634
  (_g = (_f = window === null || window === void 0 ? void 0 : window.Sentry) === null || _f === void 0 ? void 0 : _f.captureMessage) === null || _g === void 0 ? void 0 : _g.call(_f, 'Missing or malformed facet response from backend', 'error');
511
635
  }
636
+ this.setFacetsLoading(false);
512
637
  return;
513
638
  }
514
639
  const { aggregations, collectionTitles } = success.response;
@@ -520,17 +645,16 @@ export class CollectionBrowserDataSource {
520
645
  }
521
646
  this.yearHistogramAggregation =
522
647
  (_j = (_h = success === null || success === void 0 ? void 0 : success.response) === null || _h === void 0 ? void 0 : _h.aggregations) === null || _j === void 0 ? void 0 : _j.year_histogram;
523
- this.host.setFacetsLoading(false);
524
- this.host.requestUpdate();
648
+ this.setFacetsLoading(false);
649
+ this.requestHostUpdate();
525
650
  }
526
651
  /**
527
652
  * Performs the initial page fetch(es) for the current search state.
528
653
  */
529
654
  async doInitialPageFetch() {
530
- this.host.setSearchResultsLoading(true);
655
+ this.setSearchResultsLoading(true);
531
656
  // Try to batch 2 initial page requests when possible
532
657
  await this.fetchPage(this.host.initialPageNumber, 2);
533
- this.host.setSearchResultsLoading(false);
534
658
  }
535
659
  /**
536
660
  * Fetches one or more pages of results and updates the data source.
@@ -541,8 +665,7 @@ export class CollectionBrowserDataSource {
541
665
  * if `pageNumber != 1`, defaulting to a single page.
542
666
  */
543
667
  async fetchPage(pageNumber, numInitialPages = 1) {
544
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
545
- console.log(`fetchPage(${pageNumber})`, this.canPerformSearch, this.hasPage(pageNumber), this.endOfDataReached, this.host.baseQuery, JSON.stringify(this.host.selectedFacets));
668
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
546
669
  const trimmedQuery = (_a = this.host.baseQuery) === null || _a === void 0 ? void 0 : _a.trim();
547
670
  if (!this.canPerformSearch)
548
671
  return;
@@ -557,15 +680,18 @@ export class CollectionBrowserDataSource {
557
680
  const numRows = this.pageSize * numPages;
558
681
  // if a fetch is already in progress for this query and page, don't fetch again
559
682
  const { pageFetchQueryKey } = this;
560
- const pageFetches = (_b = this.pageFetchesInProgress[pageFetchQueryKey]) !== null && _b !== void 0 ? _b : new Set();
561
- if (pageFetches.has(pageNumber)) {
562
- console.log(`Skipping fetch for page ${pageNumber} because one is already in progress`);
683
+ const currentPageKey = `${pageFetchQueryKey}-p:${pageNumber}`;
684
+ console.log('page fetch key', currentPageKey, this.fetchesInProgress.has(currentPageKey));
685
+ if (this.fetchesInProgress.has(currentPageKey))
563
686
  return;
564
- }
687
+ // const pageFetches =
688
+ // this.fetchesInProgress[pageFetchQueryKey] ?? new Set();
689
+ // if (pageFetches.has(pageNumber)) return;
565
690
  for (let i = 0; i < numPages; i += 1) {
566
- pageFetches.add(pageNumber + i);
691
+ this.fetchesInProgress.add(`${pageFetchQueryKey}-p:${pageNumber + i}`);
567
692
  }
568
- this.pageFetchesInProgress[pageFetchQueryKey] = pageFetches;
693
+ console.log(`fetchPage(${pageNumber})`, this.id, this.canPerformSearch, this.hasPage(pageNumber), this.endOfDataReached, this.host.baseQuery, JSON.stringify(this.host.selectedFacets), this.pageFetchQueryKey);
694
+ this.previousQueryKey = pageFetchQueryKey;
569
695
  const sortParams = this.host.sortParam ? [this.host.sortParam] : [];
570
696
  const params = {
571
697
  ...this.pageSpecifierParams,
@@ -578,37 +704,37 @@ export class CollectionBrowserDataSource {
578
704
  };
579
705
  params.uid = await this.requestUID(params, 'hits');
580
706
  console.log('=== FIRING PAGE REQUEST ===');
581
- const searchResponse = await ((_c = this.host.searchService) === null || _c === void 0 ? void 0 : _c.search(params, this.host.searchType));
707
+ const searchResponse = await ((_b = this.host.searchService) === null || _b === void 0 ? void 0 : _b.search(params, this.host.searchType));
582
708
  console.log('=== RECEIVED PAGE RESPONSE IN CB === ');
583
709
  const success = searchResponse === null || searchResponse === void 0 ? void 0 : searchResponse.success;
584
- // This is checking to see if the query has changed since the data was fetched.
585
- // If so, we just want to discard the data since there should be a new query
586
- // right behind it.
587
- const queryChangedSinceFetch = pageFetchQueryKey !== this.pageFetchQueryKey;
588
- if (queryChangedSinceFetch)
710
+ // This is checking to see if the fetch has been invalidated since it was fired off.
711
+ // If so, we just want to discard the response since it is for an obsolete query state.
712
+ console.log('after page fetch key:', currentPageKey, this.fetchesInProgress.has(currentPageKey));
713
+ if (!this.fetchesInProgress.has(currentPageKey))
589
714
  return;
715
+ for (let i = 0; i < numPages; i += 1) {
716
+ this.fetchesInProgress.delete(`${pageFetchQueryKey}-p:${pageNumber + i}`);
717
+ }
590
718
  if (!success) {
591
- const errorMsg = (_d = searchResponse === null || searchResponse === void 0 ? void 0 : searchResponse.error) === null || _d === void 0 ? void 0 : _d.message;
592
- const detailMsg = (_f = (_e = searchResponse === null || searchResponse === void 0 ? void 0 : searchResponse.error) === null || _e === void 0 ? void 0 : _e.details) === null || _f === void 0 ? void 0 : _f.message;
593
- this.host.queryErrorMessage = `${errorMsg !== null && errorMsg !== void 0 ? errorMsg : ''}${detailMsg ? `; ${detailMsg}` : ''}`;
594
- if (!this.host.queryErrorMessage) {
595
- this.host.queryErrorMessage =
596
- 'Missing or malformed response from backend';
719
+ const errorMsg = (_c = searchResponse === null || searchResponse === void 0 ? void 0 : searchResponse.error) === null || _c === void 0 ? void 0 : _c.message;
720
+ const detailMsg = (_e = (_d = searchResponse === null || searchResponse === void 0 ? void 0 : searchResponse.error) === null || _d === void 0 ? void 0 : _d.details) === null || _e === void 0 ? void 0 : _e.message;
721
+ this.queryErrorMessage = `${errorMsg !== null && errorMsg !== void 0 ? errorMsg : ''}${detailMsg ? `; ${detailMsg}` : ''}`;
722
+ if (!this.queryErrorMessage) {
723
+ this.queryErrorMessage = 'Missing or malformed response from backend';
597
724
  // @ts-ignore: Property 'Sentry' does not exist on type 'Window & typeof globalThis'
598
- (_h = (_g = window === null || window === void 0 ? void 0 : window.Sentry) === null || _g === void 0 ? void 0 : _g.captureMessage) === null || _h === void 0 ? void 0 : _h.call(_g, this.queryErrorMessage, 'error');
599
- }
600
- for (let i = 0; i < numPages; i += 1) {
601
- (_j = this.pageFetchesInProgress[pageFetchQueryKey]) === null || _j === void 0 ? void 0 : _j.delete(pageNumber + i);
725
+ (_g = (_f = window === null || window === void 0 ? void 0 : window.Sentry) === null || _f === void 0 ? void 0 : _f.captureMessage) === null || _g === void 0 ? void 0 : _g.call(_f, this.queryErrorMessage, 'error');
602
726
  }
603
- this.host.setSearchResultsLoading(false);
604
- this.host.requestUpdate();
727
+ this.setSearchResultsLoading(false);
728
+ this.requestHostUpdate();
605
729
  return;
606
730
  }
607
731
  this.totalResults = success.response.totalResults - this.offset;
608
- this.host.setTotalResultCount(this.totalResults);
609
- // display event to offshoot when result count is zero.
610
- if (this.totalResults === 0) {
611
- this.host.emitEmptyResults();
732
+ if (this.activeOnHost) {
733
+ this.host.setTotalResultCount(this.totalResults);
734
+ // display event to offshoot when result count is zero.
735
+ if (this.totalResults === 0) {
736
+ this.host.emitEmptyResults();
737
+ }
612
738
  }
613
739
  if (this.host.withinCollection) {
614
740
  console.log('host is within collection, setting collection info:', success.response.collectionExtraInfo);
@@ -617,7 +743,7 @@ export class CollectionBrowserDataSource {
617
743
  // which can be specified in metadata, or otherwise assumed to be week:desc
618
744
  this.host.applyDefaultCollectionSort(this.collectionExtraInfo);
619
745
  if (this.collectionExtraInfo) {
620
- this.parentCollections = [].concat((_l = (_k = this.collectionExtraInfo.public_metadata) === null || _k === void 0 ? void 0 : _k.collection) !== null && _l !== void 0 ? _l : []);
746
+ this.parentCollections = [].concat((_j = (_h = this.collectionExtraInfo.public_metadata) === null || _h === void 0 ? void 0 : _h.collection) !== null && _j !== void 0 ? _j : []);
621
747
  }
622
748
  }
623
749
  else if (this.host.withinProfile) {
@@ -650,12 +776,11 @@ export class CollectionBrowserDataSource {
650
776
  if (resultCountDiscrepancy > 0) {
651
777
  console.log('End of data reached');
652
778
  this.endOfDataReached = true;
653
- this.host.setTileCount(this.totalResults);
654
- }
655
- for (let i = 0; i < numPages; i += 1) {
656
- (_m = this.pageFetchesInProgress[pageFetchQueryKey]) === null || _m === void 0 ? void 0 : _m.delete(pageNumber + i);
779
+ if (this.activeOnHost)
780
+ this.host.setTileCount(this.totalResults);
657
781
  }
658
- this.host.requestUpdate();
782
+ this.setSearchResultsLoading(false);
783
+ this.requestHostUpdate();
659
784
  }
660
785
  /**
661
786
  * Update the datasource from the fetch response
@@ -664,10 +789,6 @@ export class CollectionBrowserDataSource {
664
789
  * @param results
665
790
  */
666
791
  addTilesToDataSource(pageNumber, results) {
667
- // copy our existing datasource so when we set it below, it gets set
668
- // instead of modifying the existing dataSource since object changes
669
- // don't trigger a re-render
670
- // const datasource = { ...this.dataSource };
671
792
  const tiles = [];
672
793
  results === null || results === void 0 ? void 0 : results.forEach(result => {
673
794
  if (!result.identifier)
@@ -678,7 +799,7 @@ export class CollectionBrowserDataSource {
678
799
  const visiblePages = this.host.currentVisiblePageNumbers;
679
800
  const needsReload = visiblePages.includes(pageNumber);
680
801
  if (needsReload) {
681
- this.host.refreshVisibleResults();
802
+ this.refreshVisibleResults();
682
803
  }
683
804
  }
684
805
  /**
@@ -722,7 +843,7 @@ export class CollectionBrowserDataSource {
722
843
  acc[bucket.key.toUpperCase()] = bucket.doc_count;
723
844
  return acc;
724
845
  }, {});
725
- this.host.requestUpdate();
846
+ this.requestHostUpdate();
726
847
  }
727
848
  }
728
849
  //# sourceMappingURL=collection-browser-data-source.js.map