@internetarchive/collection-browser 1.14.17-alpha.22 → 1.14.17-alpha.23

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.
@@ -48,6 +48,12 @@ export interface CollectionBrowserDataSourceInterface
48
48
  */
49
49
  readonly endOfDataReached: boolean;
50
50
 
51
+ /**
52
+ * True if the initial work for a new query state has been completed (i.e., firing initial
53
+ * page/facet requests). False otherwise.
54
+ */
55
+ readonly queryInitialized: boolean;
56
+
51
57
  /**
52
58
  * A string key compactly representing the current full search state, which can
53
59
  * be used to determine, e.g., when a new search is required or whether an arriving
@@ -273,6 +279,11 @@ export class CollectionBrowserDataSource
273
279
  */
274
280
  endOfDataReached = false;
275
281
 
282
+ /**
283
+ * @inheritdoc
284
+ */
285
+ queryInitialized = false;
286
+
276
287
  /**
277
288
  * @inheritdoc
278
289
  */
@@ -364,7 +375,8 @@ export class CollectionBrowserDataSource
364
375
  // We should only reset if either:
365
376
  // (a) our state permits a valid search, or
366
377
  // (b) we have a blank query that we want to show empty results for
367
- const shouldShowEmptyQueryResults = this.host.clearResultsOnEmptyQuery && this.host.baseQuery === '';
378
+ const shouldShowEmptyQueryResults =
379
+ this.host.clearResultsOnEmptyQuery && this.host.baseQuery === '';
368
380
  if (!(this.canPerformSearch || shouldShowEmptyQueryResults)) return;
369
381
 
370
382
  this.handleQueryChange();
@@ -393,6 +405,7 @@ export class CollectionBrowserDataSource
393
405
  this.numTileModels = 0;
394
406
  this.totalResults = 0;
395
407
  this.endOfDataReached = false;
408
+ this.queryInitialized = false;
396
409
 
397
410
  this.host.requestUpdate();
398
411
  }
@@ -463,6 +476,7 @@ export class CollectionBrowserDataSource
463
476
  });
464
477
 
465
478
  // Fire the initial page & facet requests
479
+ this.queryInitialized = true;
466
480
  await Promise.all([
467
481
  this.doInitialPageFetch(),
468
482
  this.host.suppressFacets ? null : this.fetchFacets(),
@@ -942,7 +956,11 @@ export class CollectionBrowserDataSource
942
956
  const queryChangedSinceFetch =
943
957
  facetFetchQueryKey !== this.facetFetchQueryKey;
944
958
  if (queryChangedSinceFetch) {
945
- console.log('facet query has changed since fetch, returning. new/old:', this.facetFetchQueryKey, facetFetchQueryKey);
959
+ console.log(
960
+ 'facet query has changed since fetch, returning. new/old:',
961
+ this.facetFetchQueryKey,
962
+ facetFetchQueryKey
963
+ );
946
964
  return;
947
965
  }
948
966
 
@@ -1014,12 +1032,8 @@ export class CollectionBrowserDataSource
1014
1032
  const { pageFetchQueryKey } = this;
1015
1033
  const pageFetches =
1016
1034
  this.pageFetchesInProgress[pageFetchQueryKey] ?? new Set();
1017
- if (pageFetches.has(pageNumber)) {
1018
- console.log(
1019
- `Skipping fetch for page ${pageNumber} because one is already in progress`
1020
- );
1021
- return;
1022
- }
1035
+ if (pageFetches.has(pageNumber)) return;
1036
+
1023
1037
  for (let i = 0; i < numPages; i += 1) {
1024
1038
  pageFetches.add(pageNumber + i);
1025
1039
  }
@@ -66,7 +66,7 @@ export interface CollectionBrowserSearchInterface
66
66
  readonly initialPageNumber: number;
67
67
  readonly currentVisiblePageNumbers: number[];
68
68
  readonly clearResultsOnEmptyQuery?: boolean;
69
- readonly dataSource: CollectionBrowserDataSourceInterface;
69
+ readonly dataSource?: CollectionBrowserDataSourceInterface;
70
70
 
71
71
  getSessionId(): Promise<string>;
72
72
  setSearchResultsLoading(loading: boolean): void;
@@ -4,7 +4,7 @@ import { customElement, property } from 'lit/decorators.js';
4
4
  import { ifDefined } from 'lit/directives/if-defined.js';
5
5
  import { msg } from '@lit/localize';
6
6
 
7
- import { map } from 'lit/directives/map';
7
+ import { map } from 'lit/directives/map.js';
8
8
  import { DateFormat, formatDate } from '../../utils/format-date';
9
9
  import { isFirstMillisecondOfUTCYear } from '../../utils/local-date-from-utc';
10
10
  import { BaseTileComponent } from '../base-tile-component';
@@ -917,7 +917,7 @@ describe('Collection Browser', () => {
917
917
  el.sortDirection = 'asc';
918
918
  el.selectedCreatorFilter = 'X';
919
919
  await el.updateComplete;
920
- await el.initialSearchComplete;
920
+ await nextTick();
921
921
 
922
922
  expect(searchService.searchParams?.query).to.equal('first-creator');
923
923
  expect(searchService.searchParams?.filters?.firstCreator?.X).to.equal(
@@ -926,7 +926,7 @@ describe('Collection Browser', () => {
926
926
 
927
927
  el.baseQuery = 'collection:foo';
928
928
  await el.updateComplete;
929
- await el.initialSearchComplete;
929
+ await nextTick();
930
930
 
931
931
  expect(searchService.searchParams?.query).to.equal('collection:foo');
932
932
  expect(searchService.searchParams?.filters?.firstCreator).not.to.exist;
@@ -1446,9 +1446,6 @@ describe('Collection Browser', () => {
1446
1446
  </collection-browser>`
1447
1447
  );
1448
1448
 
1449
- await el.initialSearchComplete;
1450
- await el.updateComplete;
1451
-
1452
1449
  el.baseQuery = 'bar';
1453
1450
  await el.updateComplete;
1454
1451
 
@@ -1484,9 +1481,6 @@ describe('Collection Browser', () => {
1484
1481
  </collection-browser>`
1485
1482
  );
1486
1483
 
1487
- await el.initialSearchComplete;
1488
- await el.updateComplete;
1489
-
1490
1484
  el.withinCollection = 'bar';
1491
1485
  await el.updateComplete;
1492
1486