@internetarchive/collection-browser 1.14.17-alpha.35 → 1.14.17-alpha.37

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:
@@ -21,6 +21,8 @@ export class CollectionBrowserDataSource {
21
21
  * If this changes, we need to load new results.
22
22
  */
23
23
  this.previousQueryKey = '';
24
+ this.searchResultsLoading = false;
25
+ this.facetsLoading = false;
24
26
  // TEMP for ease of debugging
25
27
  this.id = Math.random();
26
28
  /**
@@ -111,10 +113,10 @@ export class CollectionBrowserDataSource {
111
113
  // Swap in the new pages
112
114
  this.pages = newPages;
113
115
  this.numTileModels -= numChecked;
114
- this.host.requestUpdate();
115
- this.host.refreshVisibleResults();
116
+ this.requestHostUpdate();
117
+ this.refreshVisibleResults();
116
118
  };
117
- this.host.addController(this);
119
+ //this.host.addController(this);
118
120
  }
119
121
  /**
120
122
  * @inheritdoc
@@ -127,8 +129,11 @@ export class CollectionBrowserDataSource {
127
129
  // This reactive controller hook is run whenever the host component (collection-browser) performs an update.
128
130
  // We check whether the host's state has changed in a way which should trigger a reset & new results fetch.
129
131
  // Only the currently-installed data source should react to the update
130
- if (this.host.dataSource !== this)
132
+ if (!this.activeOnHost)
131
133
  return;
134
+ // Copy loading states onto the host
135
+ this.setSearchResultsLoading(this.searchResultsLoading);
136
+ this.setFacetsLoading(this.facetsLoading);
132
137
  // Can't perform searches without a search service
133
138
  if (!this.host.searchService)
134
139
  return;
@@ -143,9 +148,16 @@ export class CollectionBrowserDataSource {
143
148
  const shouldShowEmptyQueryResults = this.host.clearResultsOnEmptyQuery && this.host.baseQuery === '';
144
149
  if (!(this.canPerformSearch || shouldShowEmptyQueryResults))
145
150
  return;
146
- this.host.emitQueryStateChanged();
151
+ if (this.activeOnHost)
152
+ this.host.emitQueryStateChanged();
147
153
  this.handleQueryChange();
148
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
+ }
149
161
  /**
150
162
  * @inheritdoc
151
163
  */
@@ -163,13 +175,15 @@ export class CollectionBrowserDataSource {
163
175
  this.pageElements = undefined;
164
176
  this.parentCollections = [];
165
177
  this.prefixFilterCountMap = {};
178
+ this.queryErrorMessage = undefined;
166
179
  this.offset = 0;
167
180
  this.numTileModels = 0;
168
181
  this.totalResults = 0;
169
182
  this.endOfDataReached = false;
170
183
  this.queryInitialized = false;
171
- this.host.setTotalResultCount(0);
172
- this.host.requestUpdate();
184
+ if (this.activeOnHost)
185
+ this.host.setTotalResultCount(0);
186
+ this.requestHostUpdate();
173
187
  }
174
188
  /**
175
189
  * @inheritdoc
@@ -177,7 +191,7 @@ export class CollectionBrowserDataSource {
177
191
  addPage(pageNum, pageTiles) {
178
192
  this.pages[pageNum] = pageTiles;
179
193
  this.numTileModels += pageTiles.length;
180
- this.host.requestUpdate();
194
+ this.requestHostUpdate();
181
195
  }
182
196
  /**
183
197
  * @inheritdoc
@@ -245,8 +259,8 @@ export class CollectionBrowserDataSource {
245
259
  page,
246
260
  tileModels.map((model, index, array) => model ? callback(model, index, array) : model),
247
261
  ]));
248
- this.host.requestUpdate();
249
- this.host.refreshVisibleResults();
262
+ this.requestHostUpdate();
263
+ this.refreshVisibleResults();
250
264
  }
251
265
  /**
252
266
  * @inheritdoc
@@ -272,7 +286,6 @@ export class CollectionBrowserDataSource {
272
286
  .flat()
273
287
  .filter((model, index, array) => model ? predicate(model, index, array) : false);
274
288
  }
275
- // DATA FETCHES
276
289
  /**
277
290
  * @inheritdoc
278
291
  */
@@ -292,6 +305,43 @@ export class CollectionBrowserDataSource {
292
305
  (isCollectionSearch && isMetadataSearch) ||
293
306
  (isProfileSearch && hasProfileElement && isMetadataSearch));
294
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
+ }
295
345
  /**
296
346
  * The query key is a string that uniquely identifies the current search.
297
347
  * It consists of:
@@ -552,7 +602,7 @@ export class CollectionBrowserDataSource {
552
602
  // The default aggregations for the search_results page type should be what we need here.
553
603
  };
554
604
  params.uid = await this.requestUID({ ...params, sort: sortParams }, 'aggregations');
555
- this.host.setFacetsLoading(true);
605
+ this.setFacetsLoading(true);
556
606
  const searchResponse = await ((_b = this.host.searchService) === null || _b === void 0 ? void 0 : _b.search(params, this.host.searchType));
557
607
  const success = searchResponse === null || searchResponse === void 0 ? void 0 : searchResponse.success;
558
608
  // This is checking to see if the query has changed since the data was fetched.
@@ -570,7 +620,7 @@ export class CollectionBrowserDataSource {
570
620
  // @ts-ignore: Property 'Sentry' does not exist on type 'Window & typeof globalThis'
571
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');
572
622
  }
573
- this.host.setFacetsLoading(false);
623
+ this.setFacetsLoading(false);
574
624
  return;
575
625
  }
576
626
  const { aggregations, collectionTitles } = success.response;
@@ -582,17 +632,17 @@ export class CollectionBrowserDataSource {
582
632
  }
583
633
  this.yearHistogramAggregation =
584
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;
585
- this.host.setFacetsLoading(false);
586
- this.host.requestUpdate();
635
+ this.setFacetsLoading(false);
636
+ this.requestHostUpdate();
587
637
  }
588
638
  /**
589
639
  * Performs the initial page fetch(es) for the current search state.
590
640
  */
591
641
  async doInitialPageFetch() {
592
- this.host.setSearchResultsLoading(true);
642
+ this.setSearchResultsLoading(true);
593
643
  // Try to batch 2 initial page requests when possible
594
644
  await this.fetchPage(this.host.initialPageNumber, 2);
595
- this.host.setSearchResultsLoading(false);
645
+ this.setSearchResultsLoading(false);
596
646
  }
597
647
  /**
598
648
  * Fetches one or more pages of results and updates the data source.
@@ -651,25 +701,26 @@ export class CollectionBrowserDataSource {
651
701
  if (!success) {
652
702
  const errorMsg = (_d = searchResponse === null || searchResponse === void 0 ? void 0 : searchResponse.error) === null || _d === void 0 ? void 0 : _d.message;
653
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;
654
- this.host.queryErrorMessage = `${errorMsg !== null && errorMsg !== void 0 ? errorMsg : ''}${detailMsg ? `; ${detailMsg}` : ''}`;
655
- if (!this.host.queryErrorMessage) {
656
- this.host.queryErrorMessage =
657
- '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';
658
707
  // @ts-ignore: Property 'Sentry' does not exist on type 'Window & typeof globalThis'
659
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');
660
709
  }
661
710
  for (let i = 0; i < numPages; i += 1) {
662
711
  (_j = this.pageFetchesInProgress[pageFetchQueryKey]) === null || _j === void 0 ? void 0 : _j.delete(pageNumber + i);
663
712
  }
664
- this.host.setSearchResultsLoading(false);
665
- this.host.requestUpdate();
713
+ this.setSearchResultsLoading(false);
714
+ this.requestHostUpdate();
666
715
  return;
667
716
  }
668
717
  this.totalResults = success.response.totalResults - this.offset;
669
- this.host.setTotalResultCount(this.totalResults);
670
- // display event to offshoot when result count is zero.
671
- if (this.totalResults === 0) {
672
- 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
+ }
673
724
  }
674
725
  if (this.host.withinCollection) {
675
726
  console.log('host is within collection, setting collection info:', success.response.collectionExtraInfo);
@@ -711,12 +762,13 @@ export class CollectionBrowserDataSource {
711
762
  if (resultCountDiscrepancy > 0) {
712
763
  console.log('End of data reached');
713
764
  this.endOfDataReached = true;
714
- this.host.setTileCount(this.totalResults);
765
+ if (this.activeOnHost)
766
+ this.host.setTileCount(this.totalResults);
715
767
  }
716
768
  for (let i = 0; i < numPages; i += 1) {
717
769
  (_m = this.pageFetchesInProgress[pageFetchQueryKey]) === null || _m === void 0 ? void 0 : _m.delete(pageNumber + i);
718
770
  }
719
- this.host.requestUpdate();
771
+ this.requestHostUpdate();
720
772
  }
721
773
  /**
722
774
  * Update the datasource from the fetch response
@@ -725,10 +777,6 @@ export class CollectionBrowserDataSource {
725
777
  * @param results
726
778
  */
727
779
  addTilesToDataSource(pageNumber, results) {
728
- // copy our existing datasource so when we set it below, it gets set
729
- // instead of modifying the existing dataSource since object changes
730
- // don't trigger a re-render
731
- // const datasource = { ...this.dataSource };
732
780
  const tiles = [];
733
781
  results === null || results === void 0 ? void 0 : results.forEach(result => {
734
782
  if (!result.identifier)
@@ -739,7 +787,7 @@ export class CollectionBrowserDataSource {
739
787
  const visiblePages = this.host.currentVisiblePageNumbers;
740
788
  const needsReload = visiblePages.includes(pageNumber);
741
789
  if (needsReload) {
742
- this.host.refreshVisibleResults();
790
+ this.refreshVisibleResults();
743
791
  }
744
792
  }
745
793
  /**
@@ -783,7 +831,7 @@ export class CollectionBrowserDataSource {
783
831
  acc[bucket.key.toUpperCase()] = bucket.doc_count;
784
832
  return acc;
785
833
  }, {});
786
- this.host.requestUpdate();
834
+ this.requestHostUpdate();
787
835
  }
788
836
  }
789
837
  //# sourceMappingURL=collection-browser-data-source.js.map