@internetarchive/collection-browser 2.5.2 → 2.6.0

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.
@@ -801,9 +801,12 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
801
801
  >
802
802
  </collection-facets>
803
803
  `;
804
- // In the desktop facets opt-in case, wrap the facet sidebar in a <details> widget
805
- // that can be opened and closed as needed.
806
- if (this.facetLoadStrategy === 'opt-in' && !this.mobileView) {
804
+ // If we are using one of the opt-in facet load strategies, we may need to wrap the
805
+ // desktop view facets in a <details> widget so that patrons can opt into loading them.
806
+ // In the `opt-in-or-login` case, we only do this if they are not logged in.
807
+ const showDesktopOptInWidget = this.facetLoadStrategy === 'opt-in' ||
808
+ (this.facetLoadStrategy === 'opt-in-or-login' && !this.loggedIn);
809
+ if (showDesktopOptInWidget && !this.mobileView) {
807
810
  return html `
808
811
  <details
809
812
  class="desktop-facets-dropdown"
@@ -1126,12 +1129,18 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
1126
1129
  * current facet loading strategy.
1127
1130
  */
1128
1131
  updateFacetReadiness() {
1129
- // In desktop view, we are always ready to load facets *unless* we are
1130
- // using the `opt-in` strategy and the facets dropdown is not open.
1131
- const desktopFacetsReady = !this.mobileView &&
1132
- (this.facetLoadStrategy !== 'opt-in' || this.collapsibleFacetsVisible);
1133
- // In mobile view, facets are considered ready provided they are currently visible (their dropdown is opened).
1134
- const mobileFacetsReady = this.mobileView && this.collapsibleFacetsVisible;
1132
+ // There are two ways to opt into facet production:
1133
+ // (1) have the facets dropdown open, or
1134
+ // (2) if using the `opt-in-or-login` strategy, be logged into an account
1135
+ const optedIn = this.collapsibleFacetsVisible ||
1136
+ (this.facetLoadStrategy === 'opt-in-or-login' && this.loggedIn);
1137
+ // In desktop view, we are always ready to load facets *unless* we are using one of the
1138
+ // `opt-in` strategies and have not opted in (whether by login or UI interaction).
1139
+ const usingOptInStrategy = ['opt-in', 'opt-in-or-login'].includes(this.facetLoadStrategy);
1140
+ const desktopFacetsReady = !this.mobileView && (!usingOptInStrategy || optedIn);
1141
+ // In the mobile view, facets are considered ready provided we have opted in (whether by
1142
+ // login or UI interaction).
1143
+ const mobileFacetsReady = this.mobileView && optedIn;
1135
1144
  this.dataSource.handleFacetReadinessChange(desktopFacetsReady || mobileFacetsReady);
1136
1145
  }
1137
1146
  /**