@@ -36,13 +36,18 @@ type AnnotatedStatuses = {
3636 active : ActiveStatus ;
3737 targetable : TargetableStatus ;
3838 archived : ArchivedStatus ;
39+ // Individual qualified statuses:
3940 activatable : ActivatableStatus ;
4041} ;
4142
4243type GuideAnnotation = AnnotatedStatuses & {
4344 // Resolved eligibility based on active, targetable and archived statuses,
4445 // which are backend driven evaluation results that are exposed for debugging.
4546 isEligible : boolean ;
47+
48+ // Resolved display qualification based on an activatable status, which
49+ // informs "when" and "where" an eligible guide can be displayed to user.
50+ isQualified : boolean ;
4651} ;
4752
4853export type AnnotatedGuide = KnockGuide & {
@@ -53,14 +58,6 @@ export type AnnotatedGuide = KnockGuide & {
5358 priority ?: number ;
5459} ;
5560
56- export const checkUsable = ( guide : AnnotatedGuide | MissingGuide ) => {
57- if ( guide . __typename === "MissingGuide" ) return false ;
58- if ( ! checkEligible ( guide ) ) return false ;
59- if ( ! guide . annotation . activatable . status ) return false ;
60-
61- return true ;
62- } ;
63-
6461// Exists and ordered in control but absent in switchboard (therefore not
6562// included in the api response), which implies a newly created guide that has
6663// never been published to switchboard.
@@ -71,6 +68,7 @@ export type UnknownGuide = {
7168 bypass_global_group_limit : false ;
7269 annotation : {
7370 isEligible : false ;
71+ isQualified : false ;
7472 } ;
7573} ;
7674
@@ -117,6 +115,11 @@ const resolveIsEligible = ({
117115 return true ;
118116} ;
119117
118+ export const resolveIsQualified = ( { activatable } : AnnotatedStatuses ) => {
119+ if ( ! activatable . status ) return false ;
120+ return true ;
121+ } ;
122+
120123type StoreStateSnapshot = Pick <
121124 KnockGuideClientStoreState ,
122125 "location" | "guides" | "guideGroups" | "ineligibleGuides" | "debug"
@@ -130,15 +133,18 @@ const annotateGuide = (
130133 const marker = ineligibleGuides [ guide . key ] ;
131134
132135 const statuses : AnnotatedStatuses = {
136+ // isEligible:
133137 active : { status : guide . active } ,
134138 targetable : marker ? toTargetableStatus ( marker ) : { status : true } ,
135- activatable : { status : checkActivatable ( guide , location ) } ,
136139 archived : marker ? toArchivedStatus ( marker ) : { status : false } ,
140+ // isQualified:
141+ activatable : { status : checkActivatable ( guide , location ) } ,
137142 } ;
138143
139144 const annotation : GuideAnnotation = {
140145 ...statuses ,
141146 isEligible : resolveIsEligible ( statuses ) ,
147+ isQualified : resolveIsQualified ( statuses ) ,
142148 } ;
143149
144150 return {
@@ -155,6 +161,7 @@ const newUnknownGuide = (key: KnockGuide["key"]) =>
155161 bypass_global_group_limit : false ,
156162 annotation : {
157163 isEligible : false ,
164+ isQualified : false ,
158165 } ,
159166 } ) as UnknownGuide ;
160167
0 commit comments