@@ -164,12 +164,9 @@ const select = (state: StoreState, filters: SelectFilterParams = {}) => {
164164 const guide = state . previewGuides [ guideKey ] || state . guides [ guideKey ] ;
165165 if ( ! guide ) continue ;
166166
167- const ineligible = ! ! state . ineligibleGuides [ guide . key ] ;
168- if ( ineligible ) continue ;
169-
170- const affirmed = predicate ( guide , {
167+ const affirmed = predicate ( guide , filters , {
171168 location,
172- filters ,
169+ ineligibleGuides : state . ineligibleGuides ,
173170 debug : state . debug ,
174171 } ) ;
175172
@@ -182,15 +179,15 @@ const select = (state: StoreState, filters: SelectFilterParams = {}) => {
182179 return result ;
183180} ;
184181
185- type PredicateOpts = {
186- location ?: string | undefined ;
187- filters ?: SelectFilterParams | undefined ;
188- debug : DebugState ;
189- } ;
182+ type PredicateOpts = Pick <
183+ StoreState ,
184+ "location" | "ineligibleGuides" | "debug"
185+ > ;
190186
191187const predicate = (
192188 guide : KnockGuide ,
193- { location, filters = { } , debug = { } } : PredicateOpts ,
189+ filters : SelectFilterParams ,
190+ { location, ineligibleGuides = { } , debug = { } } : PredicateOpts ,
194191) => {
195192 if ( filters . type && filters . type !== guide . type ) {
196193 return false ;
@@ -207,6 +204,11 @@ const predicate = (
207204 return debug . forcedGuideKey === guide . key ;
208205 }
209206
207+ const ineligible = ineligibleGuides [ guide . key ] ;
208+ if ( ineligible ) {
209+ return false ;
210+ }
211+
210212 if ( ! guide . active ) {
211213 return false ;
212214 }
@@ -375,7 +377,7 @@ export class KnockGuideClient {
375377 guideGroups : groups ?. length > 0 ? groups : [ mockDefaultGroup ( entries ) ] ,
376378 guideGroupDisplayLogs : guide_group_display_logs || { } ,
377379 guides : byKey ( entries . map ( ( g ) => this . localCopy ( g ) ) ) ,
378- ineligibleGuides : byKey ( ineligible_guides ) ,
380+ ineligibleGuides : byKey ( ineligible_guides || [ ] ) ,
379381 queries : { ...state . queries , [ queryKey ] : queryStatus } ,
380382 } ) ) ;
381383 } catch ( e ) {
@@ -476,6 +478,8 @@ export class KnockGuideClient {
476478 private handleSocketEvent ( payload : GuideSocketEvent ) {
477479 const { event, data } = payload ;
478480
481+ // TODO(KNO-11489): Include an ineligible guide in the socket payload too
482+ // and process it when handling socket events in real time.
479483 switch ( event ) {
480484 case "guide.added" :
481485 return this . addOrReplaceGuide ( payload ) ;
0 commit comments