@@ -36,27 +36,24 @@ 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 & {
4954 annotation : GuideAnnotation ;
5055} ;
5156
52- export const checkUsable = ( guide : AnnotatedGuide | MissingGuide ) => {
53- if ( guide . __typename === "MissingGuide" ) return false ;
54- if ( ! checkEligible ( guide ) ) return false ;
55- if ( ! guide . annotation . activatable . status ) return false ;
56-
57- return true ;
58- } ;
59-
6057// Exists and ordered in control but absent in switchboard (therefore not
6158// included in the api response), which implies a newly created guide that has
6259// never been published to switchboard.
@@ -67,6 +64,7 @@ export type MissingGuide = {
6764 bypass_global_group_limit : false ;
6865 annotation : {
6966 isEligible : false ;
67+ isQualified : false ;
7068 } ;
7169} ;
7270
@@ -113,6 +111,11 @@ const resolveIsEligible = ({
113111 return true ;
114112} ;
115113
114+ export const resolveIsQualified = ( { activatable } : AnnotatedStatuses ) => {
115+ if ( ! activatable . status ) return false ;
116+ return true ;
117+ } ;
118+
116119type StoreStateSnapshot = Pick <
117120 KnockGuideClientStoreState ,
118121 "location" | "guides" | "guideGroups" | "ineligibleGuides" | "debug"
@@ -126,15 +129,18 @@ const annotateGuide = (
126129 const marker = ineligibleGuides [ guide . key ] ;
127130
128131 const statuses : AnnotatedStatuses = {
132+ // isEligible:
129133 active : { status : guide . active } ,
130134 targetable : marker ? toTargetableStatus ( marker ) : { status : true } ,
131- activatable : { status : checkActivatable ( guide , location ) } ,
132135 archived : marker ? toArchivedStatus ( marker ) : { status : false } ,
136+ // isQualified:
137+ activatable : { status : checkActivatable ( guide , location ) } ,
133138 } ;
134139
135140 const annotation : GuideAnnotation = {
136141 ...statuses ,
137142 isEligible : resolveIsEligible ( statuses ) ,
143+ isQualified : resolveIsQualified ( statuses ) ,
138144 } ;
139145
140146 return {
@@ -151,6 +157,7 @@ const newMissingGuide = (key: KnockGuide["key"]) =>
151157 bypass_global_group_limit : false ,
152158 annotation : {
153159 isEligible : false ,
160+ isQualified : false ,
154161 } ,
155162 } ) as MissingGuide ;
156163
0 commit comments