@internetarchive/collection-browser 4.1.1-alpha-webdev8185.0 → 4.1.1-alpha-webdev8185.1

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.
@@ -659,22 +659,6 @@ export declare class CollectionBrowser extends LitElement implements InfiniteScr
659
659
  * Sets the total number of tiles displayed in the infinite scroller.
660
660
  */
661
661
  setTileCount(count: number): void;
662
- /**
663
- * Applies the default sort options for the TV search results page
664
- */
665
- applyDefaultTVSearchSort(): void;
666
- /**
667
- * Applies any default sort option for the current collection, by checking
668
- * for one in the collection's metadata. If none is found, defaults to sorting
669
- * descending by:
670
- * - Date Favorited for fav-* collections
671
- * - Weekly views for all other collections
672
- */
673
- applyDefaultCollectionSort(collectionInfo?: CollectionExtraInfo): void;
674
- /**
675
- * Applies the default sort option for the current profile element
676
- */
677
- applyDefaultProfileSort(): void;
678
662
  /**
679
663
  * This is useful for determining whether we need to reload the scroller.
680
664
  *
@@ -5,7 +5,7 @@ import { classMap } from 'lit/directives/class-map.js';
5
5
  import { msg } from '@lit/localize';
6
6
  import { SearchType, } from '@internetarchive/search-service';
7
7
  import '@internetarchive/infinite-scroller';
8
- import { SortField, getDefaultSelectedFacets, sortOptionFromAPIString, SORT_OPTIONS, defaultProfileElementSorts, defaultFacetDisplayOrder, tvFacetDisplayOrder, defaultSortAvailability, favoritesSortAvailability, tvSortAvailability, } from './models';
8
+ import { SortField, getDefaultSelectedFacets, SORT_OPTIONS, defaultFacetDisplayOrder, tvFacetDisplayOrder, defaultSortAvailability, favoritesSortAvailability, tvSortAvailability, } from './models';
9
9
  import { RestorationStateHandler, } from './restoration-state-handler';
10
10
  import { CollectionBrowserDataSource } from './data-source/collection-browser-data-source';
11
11
  import { FACETLESS_PAGE_ELEMENTS } from './data-source/models';
@@ -373,9 +373,6 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
373
373
  }
374
374
  willUpdate(changed) {
375
375
  this.setPlaceholderType();
376
- if (changed.has('searchType') && this.searchType === SearchType.TV) {
377
- this.applyDefaultTVSearchSort();
378
- }
379
376
  }
380
377
  render() {
381
378
  return html `
@@ -1368,19 +1365,6 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
1368
1365
  });
1369
1366
  }
1370
1367
  }
1371
- if (changed.has('profileElement')) {
1372
- this.applyDefaultProfileSort();
1373
- }
1374
- if (changed.has('withinCollection') && this.withinCollection) {
1375
- // Set a sensible default collection sort while we load results, which we will later
1376
- // adjust based on any sort-by metadata once the response arrives.
1377
- if (!this.baseQuery) {
1378
- this.defaultSortField = this.withinCollection.startsWith('fav-')
1379
- ? SortField.datefavorited
1380
- : SortField.weeklyview;
1381
- this.defaultSortDirection = 'desc';
1382
- }
1383
- }
1384
1368
  if (changed.has('baseQuery')) {
1385
1369
  this.emitBaseQueryChanged();
1386
1370
  }
@@ -1859,66 +1843,6 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
1859
1843
  this.infiniteScroller.itemCount = count;
1860
1844
  }
1861
1845
  }
1862
- /**
1863
- * Applies the default sort options for the TV search results page
1864
- */
1865
- applyDefaultTVSearchSort() {
1866
- this.defaultSortField = SortField.datearchived;
1867
- this.defaultSortDirection = 'desc';
1868
- }
1869
- /**
1870
- * Applies any default sort option for the current collection, by checking
1871
- * for one in the collection's metadata. If none is found, defaults to sorting
1872
- * descending by:
1873
- * - Date Favorited for fav-* collections
1874
- * - Weekly views for all other collections
1875
- */
1876
- applyDefaultCollectionSort(collectionInfo) {
1877
- if (this.baseQuery) {
1878
- // If there's a query set, then we default to relevance sorting regardless of
1879
- // the collection metadata-specified sort.
1880
- this.defaultSortField = SortField.relevance;
1881
- this.defaultSortDirection = null;
1882
- return;
1883
- }
1884
- // Favorite collections sort on Date Favorited by default.
1885
- // Other collections fall back to sorting on weekly views.
1886
- const baseDefaultSort = collectionInfo?.public_metadata?.identifier?.startsWith('fav-')
1887
- ? '-favoritedate'
1888
- : '-week';
1889
- // The collection metadata may override the default sorting with something else
1890
- const metadataSort = collectionInfo?.public_metadata?.['sort-by'];
1891
- // Prefer the metadata-specified sort if one exists
1892
- const defaultSortToApply = metadataSort ?? baseDefaultSort;
1893
- // Account for both -field and field:dir formats
1894
- let [field, dir] = defaultSortToApply.split(':');
1895
- if (field.startsWith('-')) {
1896
- field = field.slice(1);
1897
- dir = 'desc';
1898
- }
1899
- else if (!['asc', 'desc'].includes(dir)) {
1900
- dir = 'asc';
1901
- }
1902
- const sortOption = sortOptionFromAPIString(field);
1903
- const sortField = sortOption.field;
1904
- if (sortField && sortField !== SortField.default) {
1905
- this.defaultSortField = sortField;
1906
- this.defaultSortDirection = dir;
1907
- }
1908
- }
1909
- /**
1910
- * Applies the default sort option for the current profile element
1911
- */
1912
- applyDefaultProfileSort() {
1913
- if (this.profileElement) {
1914
- const defaultSortField = defaultProfileElementSorts[this.profileElement];
1915
- this.defaultSortField = defaultSortField ?? SortField.weeklyview;
1916
- }
1917
- else {
1918
- this.defaultSortField = SortField.weeklyview;
1919
- }
1920
- this.defaultSortDirection = 'desc';
1921
- }
1922
1846
  /**
1923
1847
  * This is useful for determining whether we need to reload the scroller.
1924
1848
  *