@internetarchive/collection-browser 1.14.17-alpha.34 → 1.14.17-alpha.36

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.
@@ -1 +1 @@
1
- {"version":3,"file":"collection-browser-data-source-interface.js","sourceRoot":"","sources":["../../../src/data-source/collection-browser-data-source-interface.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n FilterMap,\n Aggregation,\n CollectionExtraInfo,\n AccountExtraInfo,\n PageElementMap,\n} from '@internetarchive/search-service';\nimport type { ReactiveController } from 'lit';\nimport type {\n PrefixFilterType,\n PrefixFilterCounts,\n TileModel,\n} from '../models';\nimport type { PageSpecifierParams, CollectionTitles } from './models';\n\nexport interface CollectionBrowserDataSourceInterface\n extends ReactiveController {\n /**\n * How many tile models are present in this data source\n */\n readonly size: number;\n\n /**\n * How many results there are in the full result set for the current query\n * (not necessarily all loaded yet).\n */\n readonly totalResults: number;\n\n /**\n * Whether the host has a valid set of properties for performing a search.\n * For instance, on the search page this requires a valid search service and a\n * non-empty query, while collection pages allow searching with an empty query\n * for MDS but not FTS.\n */\n readonly canPerformSearch: boolean;\n\n /**\n * Whether the end of the set of results for the current query state has been\n * encountered (i.e., the last page of results).\n */\n readonly endOfDataReached: boolean;\n\n /**\n * True if the initial work for a new query state has been completed (i.e., firing initial\n * page/facet requests). False otherwise.\n */\n readonly queryInitialized: boolean;\n\n /**\n * A string key compactly representing the current full search state, which can\n * be used to determine, e.g., when a new search is required or whether an arriving\n * response is outdated.\n */\n readonly pageFetchQueryKey: string;\n\n /**\n * Similar to `pageFetchQueryKey`, but excluding properties that do not affect\n * the validity of a set of facets (e.g., sort).\n */\n readonly facetFetchQueryKey: string;\n\n /**\n * An object representing any collection- or profile-specific properties to be passed along\n * to the search service, specifying the exact page/tab to fetch results for.\n */\n readonly pageSpecifierParams: PageSpecifierParams | null;\n\n /**\n * A FilterMap object representing all filters applied to the current search,\n * including any facets, letter filters, and date ranges.\n */\n readonly filterMap: FilterMap;\n\n /**\n * The full set of aggregations retrieved for the current search.\n */\n readonly aggregations?: Record<string, Aggregation>;\n\n /**\n * The `year_histogram` aggregation retrieved for the current search.\n */\n readonly yearHistogramAggregation?: Aggregation;\n\n /**\n * A map from collection identifiers that appear on hits or aggregations for the\n * current search, to their human-readable collection titles.\n */\n readonly collectionTitles: CollectionTitles;\n\n /**\n * The \"extra info\" package provided by the PPS for collection pages, including details\n * used to populate the target collection header & About tab content.\n */\n readonly collectionExtraInfo?: CollectionExtraInfo;\n\n /**\n * The \"extra info\" package provided by the PPS for profile pages, including details\n * used to populate the profile header.\n */\n readonly accountExtraInfo?: AccountExtraInfo;\n\n /**\n * The set of requested page elements for profile pages, if applicable. These represent\n * any content specific to the current profile tab.\n */\n readonly pageElements?: PageElementMap;\n\n /**\n * An array of the current target collection's parent collections. Should include *all*\n * ancestors in the collection hierarchy, not just the immediate parent.\n */\n readonly parentCollections?: string[];\n\n /**\n * An object storing result counts for the current search bucketed by letter prefix.\n * Keys are the result field on which the prefixes are considered (e.g., title/creator)\n * and values are a Record mapping letters to their counts.\n */\n readonly prefixFilterCountMap: Partial<\n Record<PrefixFilterType, PrefixFilterCounts>\n >;\n\n /**\n * An array of all the tile models whose management checkboxes are checked\n */\n readonly checkedTileModels: TileModel[];\n\n /**\n * An array of all the tile models whose management checkboxes are unchecked\n */\n readonly uncheckedTileModels: TileModel[];\n\n /**\n * A Promise which, after each query change, resolves once the fetches for the initial\n * search have completed. Waits for *both* the hits and aggregations fetches to finish.\n *\n * Ensure you await this component's `updateComplete` promise before awaiting this\n * one, to ensure you do not await an obsolete promise from the previous update.\n */\n readonly initialSearchComplete: Promise<boolean>;\n\n /**\n * Resets the data source to its empty state, with no result pages, aggregations, etc.\n */\n reset(): void;\n\n /**\n * Adds the given page of tile models to the data source.\n * If the given page number already exists, that page will be overwritten.\n * @param pageNum Which page number to add (indexed starting from 1)\n * @param pageTiles The array of tile models for the new page\n */\n addPage(pageNum: number, pageTiles: TileModel[]): void;\n\n /**\n * Returns the given page of tile models from the data source.\n * @param pageNum Which page number to get (indexed starting from 1)\n */\n getPage(pageNum: number): TileModel[];\n\n /**\n * Returns the full set of paged tile models stored in this data source.\n */\n getAllPages(): Record<string, TileModel[]>;\n\n /**\n * Whether the data source contains any tiles for the given page number.\n * @param pageNum Which page number to query (indexed starting from 1)\n */\n hasPage(pageNum: number): boolean;\n\n /**\n * Returns the single tile model appearing at the given index in the\n * data source, with respect to the current page size. Returns `undefined` if\n * the corresponding page is not present on the data source or if it does not\n * contain a tile model at the corresponding index.\n * @param index The 0-based index (within the full data source) of the tile to get\n */\n getTileModelAt(index: number): TileModel | undefined;\n\n /**\n * Returns the first numeric tile index corresponding to the given tile model object,\n * or -1 if the given tile model is not present.\n * @param tile The tile model to search for in the data source\n */\n indexOf(tile: TileModel): number;\n\n /**\n * Requests that the data source fire a backend request for the given page of results.\n * @param pageNum Which page number to fetch results for\n * @param numInitialPages How many pages should be batched together on an initial fetch\n */\n fetchPage(pageNum: number, numInitialPages?: number): Promise<void>;\n\n /**\n * Requests that the data source update its prefix bucket result counts for the given\n * type of prefix filter.\n * @param filterType Which prefixable field to update the buckets for (e.g., title/creator)\n */\n updatePrefixFilterCounts(filterType: PrefixFilterType): Promise<void>;\n\n /**\n * Changes the page size used by the data source, discarding any previously-fetched pages.\n *\n * **Note: this operation will reset any data stored in the data source!**\n * @param pageSize\n */\n setPageSize(pageSize: number): void;\n\n /**\n * Notifies the data source that a query change has occurred, which may trigger a data\n * reset & new fetches.\n */\n handleQueryChange(): void;\n\n /**\n * Applies the given map function to all of the tile models in every page of the data\n * source.\n * @param callback A callback function to apply on each tile model, as with Array.map\n */\n map(\n callback: (model: TileModel, index: number, array: TileModel[]) => TileModel\n ): void;\n\n /**\n * Checks every tile's management checkbox\n */\n checkAllTiles(): void;\n\n /**\n * Unchecks every tile's management checkbox\n */\n uncheckAllTiles(): void;\n\n /**\n * Removes all tile models that are currently checked & adjusts the paging\n * of the data source to account for any new gaps in the data.\n */\n removeCheckedTiles(): void;\n}\n"]}
1
+ {"version":3,"file":"collection-browser-data-source-interface.js","sourceRoot":"","sources":["../../../src/data-source/collection-browser-data-source-interface.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n FilterMap,\n Aggregation,\n CollectionExtraInfo,\n AccountExtraInfo,\n PageElementMap,\n} from '@internetarchive/search-service';\nimport type { ReactiveController } from 'lit';\nimport type {\n PrefixFilterType,\n PrefixFilterCounts,\n TileModel,\n} from '../models';\nimport type { PageSpecifierParams, CollectionTitles } from './models';\n\nexport interface CollectionBrowserDataSourceInterface\n extends ReactiveController {\n /**\n * How many tile models are present in this data source\n */\n readonly size: number;\n\n /**\n * How many results there are in the full result set for the current query\n * (not necessarily all loaded yet).\n */\n readonly totalResults: number;\n\n /**\n * Whether the host has a valid set of properties for performing a search.\n * For instance, on the search page this requires a valid search service and a\n * non-empty query, while collection pages allow searching with an empty query\n * for MDS but not FTS.\n */\n readonly canPerformSearch: boolean;\n\n /**\n * Whether the end of the set of results for the current query state has been\n * encountered (i.e., the last page of results).\n */\n readonly endOfDataReached: boolean;\n\n /**\n * True if the initial work for a new query state has been completed (i.e., firing initial\n * page/facet requests). False otherwise.\n */\n readonly queryInitialized: boolean;\n\n /**\n * A string key compactly representing the current full search state, which can\n * be used to determine, e.g., when a new search is required or whether an arriving\n * response is outdated.\n */\n readonly pageFetchQueryKey: string;\n\n /**\n * Similar to `pageFetchQueryKey`, but excluding properties that do not affect\n * the validity of a set of facets (e.g., sort).\n */\n readonly facetFetchQueryKey: string;\n\n /**\n * An object representing any collection- or profile-specific properties to be passed along\n * to the search service, specifying the exact page/tab to fetch results for.\n */\n readonly pageSpecifierParams: PageSpecifierParams | null;\n\n /**\n * A FilterMap object representing all filters applied to the current search,\n * including any facets, letter filters, and date ranges.\n */\n readonly filterMap: FilterMap;\n\n /**\n * The full set of aggregations retrieved for the current search.\n */\n readonly aggregations?: Record<string, Aggregation>;\n\n /**\n * The `year_histogram` aggregation retrieved for the current search.\n */\n readonly yearHistogramAggregation?: Aggregation;\n\n /**\n * A map from collection identifiers that appear on hits or aggregations for the\n * current search, to their human-readable collection titles.\n */\n readonly collectionTitles: CollectionTitles;\n\n /**\n * The \"extra info\" package provided by the PPS for collection pages, including details\n * used to populate the target collection header & About tab content.\n */\n readonly collectionExtraInfo?: CollectionExtraInfo;\n\n /**\n * The \"extra info\" package provided by the PPS for profile pages, including details\n * used to populate the profile header.\n */\n readonly accountExtraInfo?: AccountExtraInfo;\n\n /**\n * The set of requested page elements for profile pages, if applicable. These represent\n * any content specific to the current profile tab.\n */\n readonly pageElements?: PageElementMap;\n\n /**\n * An array of the current target collection's parent collections. Should include *all*\n * ancestors in the collection hierarchy, not just the immediate parent.\n */\n readonly parentCollections?: string[];\n\n /**\n * An object storing result counts for the current search bucketed by letter prefix.\n * Keys are the result field on which the prefixes are considered (e.g., title/creator)\n * and values are a Record mapping letters to their counts.\n */\n readonly prefixFilterCountMap: Partial<\n Record<PrefixFilterType, PrefixFilterCounts>\n >;\n\n /**\n * Any error message from the most recent search results response.\n */\n readonly queryErrorMessage?: string;\n\n /**\n * An array of all the tile models whose management checkboxes are checked\n */\n readonly checkedTileModels: TileModel[];\n\n /**\n * An array of all the tile models whose management checkboxes are unchecked\n */\n readonly uncheckedTileModels: TileModel[];\n\n /**\n * A Promise which, after each query change, resolves once the fetches for the initial\n * search have completed. Waits for *both* the hits and aggregations fetches to finish.\n *\n * Ensure you await this component's `updateComplete` promise before awaiting this\n * one, to ensure you do not await an obsolete promise from the previous update.\n */\n readonly initialSearchComplete: Promise<boolean>;\n\n /**\n * Resets the data source to its empty state, with no result pages, aggregations, etc.\n */\n reset(): void;\n\n /**\n * Adds the given page of tile models to the data source.\n * If the given page number already exists, that page will be overwritten.\n * @param pageNum Which page number to add (indexed starting from 1)\n * @param pageTiles The array of tile models for the new page\n */\n addPage(pageNum: number, pageTiles: TileModel[]): void;\n\n /**\n * Returns the given page of tile models from the data source.\n * @param pageNum Which page number to get (indexed starting from 1)\n */\n getPage(pageNum: number): TileModel[];\n\n /**\n * Returns the full set of paged tile models stored in this data source.\n */\n getAllPages(): Record<string, TileModel[]>;\n\n /**\n * Whether the data source contains any tiles for the given page number.\n * @param pageNum Which page number to query (indexed starting from 1)\n */\n hasPage(pageNum: number): boolean;\n\n /**\n * Returns the single tile model appearing at the given index in the\n * data source, with respect to the current page size. Returns `undefined` if\n * the corresponding page is not present on the data source or if it does not\n * contain a tile model at the corresponding index.\n * @param index The 0-based index (within the full data source) of the tile to get\n */\n getTileModelAt(index: number): TileModel | undefined;\n\n /**\n * Returns the first numeric tile index corresponding to the given tile model object,\n * or -1 if the given tile model is not present.\n * @param tile The tile model to search for in the data source\n */\n indexOf(tile: TileModel): number;\n\n /**\n * Requests that the data source fire a backend request for the given page of results.\n * @param pageNum Which page number to fetch results for\n * @param numInitialPages How many pages should be batched together on an initial fetch\n */\n fetchPage(pageNum: number, numInitialPages?: number): Promise<void>;\n\n /**\n * Requests that the data source update its prefix bucket result counts for the given\n * type of prefix filter.\n * @param filterType Which prefixable field to update the buckets for (e.g., title/creator)\n */\n updatePrefixFilterCounts(filterType: PrefixFilterType): Promise<void>;\n\n /**\n * Changes the page size used by the data source, discarding any previously-fetched pages.\n *\n * **Note: this operation will reset any data stored in the data source!**\n * @param pageSize\n */\n setPageSize(pageSize: number): void;\n\n /**\n * Notifies the data source that a query change has occurred, which may trigger a data\n * reset & new fetches.\n */\n handleQueryChange(): void;\n\n /**\n * Applies the given map function to all of the tile models in every page of the data\n * source.\n * @param callback A callback function to apply on each tile model, as with Array.map\n */\n map(\n callback: (model: TileModel, index: number, array: TileModel[]) => TileModel\n ): void;\n\n /**\n * Checks every tile's management checkbox\n */\n checkAllTiles(): void;\n\n /**\n * Unchecks every tile's management checkbox\n */\n uncheckAllTiles(): void;\n\n /**\n * Removes all tile models that are currently checked & adjusts the paging\n * of the data source to account for any new gaps in the data.\n */\n removeCheckedTiles(): void;\n}\n"]}
@@ -21,6 +21,8 @@ export declare class CollectionBrowserDataSource implements CollectionBrowserDat
21
21
  * If this changes, we need to load new results.
22
22
  */
23
23
  private previousQueryKey;
24
+ private searchResultsLoading;
25
+ private facetsLoading;
24
26
  private id;
25
27
  /**
26
28
  * @inheritdoc
@@ -66,6 +68,10 @@ export declare class CollectionBrowserDataSource implements CollectionBrowserDat
66
68
  * @inheritdoc
67
69
  */
68
70
  prefixFilterCountMap: Partial<Record<PrefixFilterType, PrefixFilterCounts>>;
71
+ /**
72
+ * @inheritdoc
73
+ */
74
+ queryErrorMessage?: string;
69
75
  /**
70
76
  * Internal property to store the `resolve` function for the most recent
71
77
  * `initialSearchComplete` promise, allowing us to resolve it at the appropriate time.
@@ -85,6 +91,10 @@ export declare class CollectionBrowserDataSource implements CollectionBrowserDat
85
91
  /** Default size of result pages */
86
92
  pageSize: number);
87
93
  hostUpdate(): void;
94
+ /**
95
+ * Returns whether this data source is the one currently installed on the host component.
96
+ */
97
+ private get activeOnHost();
88
98
  /**
89
99
  * @inheritdoc
90
100
  */
@@ -161,6 +171,25 @@ export declare class CollectionBrowserDataSource implements CollectionBrowserDat
161
171
  * @inheritdoc
162
172
  */
163
173
  get canPerformSearch(): boolean;
174
+ /**
175
+ * Sets the state for whether the initial set of search results for the
176
+ * current query is loading
177
+ */
178
+ private setSearchResultsLoading;
179
+ /**
180
+ * Sets the state for whether the facets for a query is loading
181
+ */
182
+ private setFacetsLoading;
183
+ /**
184
+ * Requests that the host perform an update, provided this data
185
+ * source is actively installed on it.
186
+ */
187
+ private requestHostUpdate;
188
+ /**
189
+ * Requests that the host refresh its visible tiles, provided this
190
+ * data source is actively installed on it.
191
+ */
192
+ private refreshVisibleResults;
164
193
  /**
165
194
  * The query key is a string that uniquely identifies the current search.
166
195
  * It consists of:
@@ -2,7 +2,6 @@ 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
6
5
  constructor(
7
6
  /** The host element to which this controller should attach listeners */
8
7
  host,
@@ -22,6 +21,8 @@ export class CollectionBrowserDataSource {
22
21
  * If this changes, we need to load new results.
23
22
  */
24
23
  this.previousQueryKey = '';
24
+ this.searchResultsLoading = false;
25
+ this.facetsLoading = false;
25
26
  // TEMP for ease of debugging
26
27
  this.id = Math.random();
27
28
  /**
@@ -112,10 +113,10 @@ export class CollectionBrowserDataSource {
112
113
  // Swap in the new pages
113
114
  this.pages = newPages;
114
115
  this.numTileModels -= numChecked;
115
- this.host.requestUpdate();
116
- this.host.refreshVisibleResults();
116
+ this.requestHostUpdate();
117
+ this.refreshVisibleResults();
117
118
  };
118
- // No setup needed here, just defining properties
119
+ this.host.addController(this);
119
120
  }
120
121
  /**
121
122
  * @inheritdoc
@@ -128,8 +129,11 @@ export class CollectionBrowserDataSource {
128
129
  // This reactive controller hook is run whenever the host component (collection-browser) performs an update.
129
130
  // We check whether the host's state has changed in a way which should trigger a reset & new results fetch.
130
131
  // Only the currently-installed data source should react to the update
131
- if (this.host.dataSource !== this)
132
+ if (!this.activeOnHost)
132
133
  return;
134
+ // Copy loading states onto the host
135
+ this.setSearchResultsLoading(this.searchResultsLoading);
136
+ this.setFacetsLoading(this.facetsLoading);
133
137
  // Can't perform searches without a search service
134
138
  if (!this.host.searchService)
135
139
  return;
@@ -144,9 +148,16 @@ export class CollectionBrowserDataSource {
144
148
  const shouldShowEmptyQueryResults = this.host.clearResultsOnEmptyQuery && this.host.baseQuery === '';
145
149
  if (!(this.canPerformSearch || shouldShowEmptyQueryResults))
146
150
  return;
147
- this.host.emitQueryStateChanged();
151
+ if (this.activeOnHost)
152
+ this.host.emitQueryStateChanged();
148
153
  this.handleQueryChange();
149
154
  }
155
+ /**
156
+ * Returns whether this data source is the one currently installed on the host component.
157
+ */
158
+ get activeOnHost() {
159
+ return this.host.dataSource === this;
160
+ }
150
161
  /**
151
162
  * @inheritdoc
152
163
  */
@@ -164,13 +175,15 @@ export class CollectionBrowserDataSource {
164
175
  this.pageElements = undefined;
165
176
  this.parentCollections = [];
166
177
  this.prefixFilterCountMap = {};
178
+ this.queryErrorMessage = undefined;
167
179
  this.offset = 0;
168
180
  this.numTileModels = 0;
169
181
  this.totalResults = 0;
170
182
  this.endOfDataReached = false;
171
183
  this.queryInitialized = false;
172
- this.host.setTotalResultCount(0);
173
- this.host.requestUpdate();
184
+ if (this.activeOnHost)
185
+ this.host.setTotalResultCount(0);
186
+ this.requestHostUpdate();
174
187
  }
175
188
  /**
176
189
  * @inheritdoc
@@ -178,7 +191,7 @@ export class CollectionBrowserDataSource {
178
191
  addPage(pageNum, pageTiles) {
179
192
  this.pages[pageNum] = pageTiles;
180
193
  this.numTileModels += pageTiles.length;
181
- this.host.requestUpdate();
194
+ this.requestHostUpdate();
182
195
  }
183
196
  /**
184
197
  * @inheritdoc
@@ -246,8 +259,8 @@ export class CollectionBrowserDataSource {
246
259
  page,
247
260
  tileModels.map((model, index, array) => model ? callback(model, index, array) : model),
248
261
  ]));
249
- this.host.requestUpdate();
250
- this.host.refreshVisibleResults();
262
+ this.requestHostUpdate();
263
+ this.refreshVisibleResults();
251
264
  }
252
265
  /**
253
266
  * @inheritdoc
@@ -273,7 +286,6 @@ export class CollectionBrowserDataSource {
273
286
  .flat()
274
287
  .filter((model, index, array) => model ? predicate(model, index, array) : false);
275
288
  }
276
- // DATA FETCHES
277
289
  /**
278
290
  * @inheritdoc
279
291
  */
@@ -293,6 +305,43 @@ export class CollectionBrowserDataSource {
293
305
  (isCollectionSearch && isMetadataSearch) ||
294
306
  (isProfileSearch && hasProfileElement && isMetadataSearch));
295
307
  }
308
+ /**
309
+ * Sets the state for whether the initial set of search results for the
310
+ * current query is loading
311
+ */
312
+ setSearchResultsLoading(loading) {
313
+ this.searchResultsLoading = loading;
314
+ if (this.activeOnHost) {
315
+ this.host.setSearchResultsLoading(loading);
316
+ }
317
+ }
318
+ /**
319
+ * Sets the state for whether the facets for a query is loading
320
+ */
321
+ setFacetsLoading(loading) {
322
+ this.facetsLoading = loading;
323
+ if (this.activeOnHost) {
324
+ this.host.setFacetsLoading(loading);
325
+ }
326
+ }
327
+ /**
328
+ * Requests that the host perform an update, provided this data
329
+ * source is actively installed on it.
330
+ */
331
+ requestHostUpdate() {
332
+ if (this.activeOnHost) {
333
+ this.host.requestUpdate();
334
+ }
335
+ }
336
+ /**
337
+ * Requests that the host refresh its visible tiles, provided this
338
+ * data source is actively installed on it.
339
+ */
340
+ refreshVisibleResults() {
341
+ if (this.activeOnHost) {
342
+ this.host.refreshVisibleResults();
343
+ }
344
+ }
296
345
  /**
297
346
  * The query key is a string that uniquely identifies the current search.
298
347
  * It consists of:
@@ -553,7 +602,7 @@ export class CollectionBrowserDataSource {
553
602
  // The default aggregations for the search_results page type should be what we need here.
554
603
  };
555
604
  params.uid = await this.requestUID({ ...params, sort: sortParams }, 'aggregations');
556
- this.host.setFacetsLoading(true);
605
+ this.setFacetsLoading(true);
557
606
  const searchResponse = await ((_b = this.host.searchService) === null || _b === void 0 ? void 0 : _b.search(params, this.host.searchType));
558
607
  const success = searchResponse === null || searchResponse === void 0 ? void 0 : searchResponse.success;
559
608
  // This is checking to see if the query has changed since the data was fetched.
@@ -571,7 +620,7 @@ export class CollectionBrowserDataSource {
571
620
  // @ts-ignore: Property 'Sentry' does not exist on type 'Window & typeof globalThis'
572
621
  (_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');
573
622
  }
574
- this.host.setFacetsLoading(false);
623
+ this.setFacetsLoading(false);
575
624
  return;
576
625
  }
577
626
  const { aggregations, collectionTitles } = success.response;
@@ -583,17 +632,17 @@ export class CollectionBrowserDataSource {
583
632
  }
584
633
  this.yearHistogramAggregation =
585
634
  (_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;
586
- this.host.setFacetsLoading(false);
587
- this.host.requestUpdate();
635
+ this.setFacetsLoading(false);
636
+ this.requestHostUpdate();
588
637
  }
589
638
  /**
590
639
  * Performs the initial page fetch(es) for the current search state.
591
640
  */
592
641
  async doInitialPageFetch() {
593
- this.host.setSearchResultsLoading(true);
642
+ this.setSearchResultsLoading(true);
594
643
  // Try to batch 2 initial page requests when possible
595
644
  await this.fetchPage(this.host.initialPageNumber, 2);
596
- this.host.setSearchResultsLoading(false);
645
+ this.setSearchResultsLoading(false);
597
646
  }
598
647
  /**
599
648
  * Fetches one or more pages of results and updates the data source.
@@ -652,25 +701,26 @@ export class CollectionBrowserDataSource {
652
701
  if (!success) {
653
702
  const errorMsg = (_d = searchResponse === null || searchResponse === void 0 ? void 0 : searchResponse.error) === null || _d === void 0 ? void 0 : _d.message;
654
703
  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;
655
- this.host.queryErrorMessage = `${errorMsg !== null && errorMsg !== void 0 ? errorMsg : ''}${detailMsg ? `; ${detailMsg}` : ''}`;
656
- if (!this.host.queryErrorMessage) {
657
- this.host.queryErrorMessage =
658
- 'Missing or malformed response from backend';
704
+ this.queryErrorMessage = `${errorMsg !== null && errorMsg !== void 0 ? errorMsg : ''}${detailMsg ? `; ${detailMsg}` : ''}`;
705
+ if (!this.queryErrorMessage) {
706
+ this.queryErrorMessage = 'Missing or malformed response from backend';
659
707
  // @ts-ignore: Property 'Sentry' does not exist on type 'Window & typeof globalThis'
660
708
  (_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');
661
709
  }
662
710
  for (let i = 0; i < numPages; i += 1) {
663
711
  (_j = this.pageFetchesInProgress[pageFetchQueryKey]) === null || _j === void 0 ? void 0 : _j.delete(pageNumber + i);
664
712
  }
665
- this.host.setSearchResultsLoading(false);
666
- this.host.requestUpdate();
713
+ this.setSearchResultsLoading(false);
714
+ this.requestHostUpdate();
667
715
  return;
668
716
  }
669
717
  this.totalResults = success.response.totalResults - this.offset;
670
- this.host.setTotalResultCount(this.totalResults);
671
- // display event to offshoot when result count is zero.
672
- if (this.totalResults === 0) {
673
- this.host.emitEmptyResults();
718
+ if (this.activeOnHost) {
719
+ this.host.setTotalResultCount(this.totalResults);
720
+ // display event to offshoot when result count is zero.
721
+ if (this.totalResults === 0) {
722
+ this.host.emitEmptyResults();
723
+ }
674
724
  }
675
725
  if (this.host.withinCollection) {
676
726
  console.log('host is within collection, setting collection info:', success.response.collectionExtraInfo);
@@ -712,12 +762,13 @@ export class CollectionBrowserDataSource {
712
762
  if (resultCountDiscrepancy > 0) {
713
763
  console.log('End of data reached');
714
764
  this.endOfDataReached = true;
715
- this.host.setTileCount(this.totalResults);
765
+ if (this.activeOnHost)
766
+ this.host.setTileCount(this.totalResults);
716
767
  }
717
768
  for (let i = 0; i < numPages; i += 1) {
718
769
  (_m = this.pageFetchesInProgress[pageFetchQueryKey]) === null || _m === void 0 ? void 0 : _m.delete(pageNumber + i);
719
770
  }
720
- this.host.requestUpdate();
771
+ this.requestHostUpdate();
721
772
  }
722
773
  /**
723
774
  * Update the datasource from the fetch response
@@ -726,10 +777,6 @@ export class CollectionBrowserDataSource {
726
777
  * @param results
727
778
  */
728
779
  addTilesToDataSource(pageNumber, results) {
729
- // copy our existing datasource so when we set it below, it gets set
730
- // instead of modifying the existing dataSource since object changes
731
- // don't trigger a re-render
732
- // const datasource = { ...this.dataSource };
733
780
  const tiles = [];
734
781
  results === null || results === void 0 ? void 0 : results.forEach(result => {
735
782
  if (!result.identifier)
@@ -740,7 +787,7 @@ export class CollectionBrowserDataSource {
740
787
  const visiblePages = this.host.currentVisiblePageNumbers;
741
788
  const needsReload = visiblePages.includes(pageNumber);
742
789
  if (needsReload) {
743
- this.host.refreshVisibleResults();
790
+ this.refreshVisibleResults();
744
791
  }
745
792
  }
746
793
  /**
@@ -784,7 +831,7 @@ export class CollectionBrowserDataSource {
784
831
  acc[bucket.key.toUpperCase()] = bucket.doc_count;
785
832
  return acc;
786
833
  }, {});
787
- this.host.requestUpdate();
834
+ this.requestHostUpdate();
788
835
  }
789
836
  }
790
837
  //# sourceMappingURL=collection-browser-data-source.js.map