@@ -22,6 +22,7 @@ import { FormControl } from '@angular/forms';
2222import { ActivatedRoute , Router , RouterLink } from '@angular/router' ;
2323
2424import { ENVIRONMENT } from '@core/provider/environment.provider' ;
25+ import { UserSelectors } from '@core/store/user' ;
2526import { GlobalSearchComponent } from '@osf/shared/components/global-search/global-search.component' ;
2627import { LoadingSpinnerComponent } from '@osf/shared/components/loading-spinner/loading-spinner.component' ;
2728import { SearchInputComponent } from '@osf/shared/components/search-input/search-input.component' ;
@@ -41,6 +42,7 @@ import {
4142 SetSearchValue ,
4243} from '@osf/shared/stores/collections' ;
4344import { ResetSearchState , SetDefaultFilterValue , SetExtraFilters } from '@osf/shared/stores/global-search' ;
45+ import { COLLECTION_SUBMISSION_WITH_CEDAR } from '@shared/constants/feature-flags.const' ;
4446
4547import { CollectionsQuerySyncService } from '../../services' ;
4648import { CollectionsHelpDialogComponent } from '../collections-help-dialog/collections-help-dialog.component' ;
@@ -78,7 +80,8 @@ export class CollectionsDiscoverComponent {
7880 providerId = signal < string > ( '' ) ;
7981 defaultSearchFiltersInitialized = signal ( false ) ;
8082
81- readonly useShareTroveSearch = this . environment . collectionSubmissionWithCedar ;
83+ activeFlags = select ( UserSelectors . getActiveFlags ) ;
84+ readonly useShareTroveSearch = computed ( ( ) => this . activeFlags ( ) . includes ( COLLECTION_SUBMISSION_WITH_CEDAR ) ) ;
8285
8386 collectionProvider = select ( CollectionsSelectors . getCollectionProvider ) ;
8487 collectionDetails = select ( CollectionsSelectors . getCollectionDetails ) ;
@@ -106,20 +109,16 @@ export class CollectionsDiscoverComponent {
106109 constructor ( ) {
107110 this . initializeProvider ( ) ;
108111 this . setupBrandingEffect ( ) ;
109-
110- if ( this . useShareTroveSearch ) {
111- this . setupShareTroveSearchEffect ( ) ;
112- } else {
113- this . setupCollectionDetailsEffect ( ) ;
114- this . setupUrlSyncEffect ( ) ;
115- this . setupLegacySearchEffect ( ) ;
116- this . setupSearchBinding ( ) ;
117- }
112+ this . setupShareTroveSearchEffect ( ) ;
113+ this . setupCollectionDetailsEffect ( ) ;
114+ this . setupUrlSyncEffect ( ) ;
115+ this . setupLegacySearchEffect ( ) ;
116+ this . setupSearchBinding ( ) ;
118117
119118 this . destroyRef . onDestroy ( ( ) => {
120119 if ( this . isBrowser ) {
121120 this . actions . clearCollections ( ) ;
122- if ( this . useShareTroveSearch ) {
121+ if ( this . useShareTroveSearch ( ) ) {
123122 this . actions . resetSearchState ( ) ;
124123 }
125124 this . headerStyleHelper . resetToDefaults ( ) ;
@@ -133,7 +132,7 @@ export class CollectionsDiscoverComponent {
133132 }
134133
135134 onSearchTriggered ( searchValue : string ) : void {
136- if ( ! this . useShareTroveSearch ) {
135+ if ( ! this . useShareTroveSearch ( ) ) {
137136 this . actions . setSearchValue ( searchValue ) ;
138137 this . actions . setPageNumber ( '1' ) ;
139138 }
@@ -166,7 +165,7 @@ export class CollectionsDiscoverComponent {
166165 const provider = this . collectionProvider ( ) ;
167166 const collectionId = this . primaryCollectionId ( ) ;
168167
169- if ( ! provider || ! collectionId || this . defaultSearchFiltersInitialized ( ) ) return ;
168+ if ( ! this . useShareTroveSearch ( ) || ! provider || ! collectionId || this . defaultSearchFiltersInitialized ( ) ) return ;
170169
171170 const collectionIri = `${ this . environment . apiDomainUrl } /v2/collections/${ collectionId } /` ;
172171 this . actions . setDefaultFilterValue ( 'isContainedBy' , collectionIri ) ;
@@ -184,6 +183,8 @@ export class CollectionsDiscoverComponent {
184183
185184 private setupCollectionDetailsEffect ( ) : void {
186185 effect ( ( ) => {
186+ if ( this . useShareTroveSearch ( ) ) return ;
187+
187188 const collectionId = this . primaryCollectionId ( ) ;
188189 if ( collectionId ) {
189190 this . actions . getCollectionDetails ( collectionId ) ;
@@ -192,9 +193,10 @@ export class CollectionsDiscoverComponent {
192193 }
193194
194195 private setupUrlSyncEffect ( ) : void {
195- this . querySyncService . initializeFromUrl ( ) ;
196-
197196 effect ( ( ) => {
197+ if ( this . useShareTroveSearch ( ) ) return ;
198+ this . querySyncService . initializeFromUrl ( ) ;
199+
198200 const searchText = this . searchText ( ) ;
199201 const sortBy = this . sortBy ( ) ;
200202 const selectedFilters = this . selectedFilters ( ) ;
@@ -208,6 +210,8 @@ export class CollectionsDiscoverComponent {
208210
209211 private setupLegacySearchEffect ( ) : void {
210212 effect ( ( ) => {
213+ if ( this . useShareTroveSearch ( ) ) return ;
214+
211215 const searchText = this . searchText ( ) ;
212216 const sortBy = this . sortBy ( ) ;
213217 const selectedFilters = this . selectedFilters ( ) ;
0 commit comments