66 acceptedKey,
77 variantModeKey,
88} = require ( "./privacyKeys" ) ;
9+ const {
10+ getGuardianEmails
11+ } = require ( "../getTypeSafeUser" ) ;
912
1013const userDB = firebase . firestore ( ) . collection ( "users" ) ;
1114
@@ -41,6 +44,10 @@ const isUnderThirteen = (user) => {
4144 return false ;
4245 }
4346
47+ if ( user . code ) {
48+ return false ; // assume teachers are over 13
49+ }
50+
4451 return true ;
4552} ;
4653
@@ -56,8 +63,8 @@ const getPrivacyVariant = (user) => {
5663 }
5764}
5865
59- const shouldRetryPopup = ( lastTouched , isUnder13 ) => {
60- if ( isUnder13 ) return false ;
66+ const shouldRetryPopup = ( lastTouched , isUnder13 , guardianEmails ) => {
67+ if ( isUnder13 && guardianEmails . length ) return false ;
6168
6269 try {
6370 if ( ! lastTouched ) return false ;
@@ -71,21 +78,10 @@ const shouldRetryPopup = (lastTouched, isUnder13) => {
7178const getPrivacyState = ( email , user ) => {
7279 const isUnder13 = isUnderThirteen ( user ) ;
7380 const variant = getPrivacyVariant ( user ) ;
81+ const guardianEmails = getGuardianEmails ( user ) ;
7482
7583 const useUnder13 = isUnder13 && variant !== 'year8webinar'
7684
77- if (
78- ! email . includes ( "@mcmill.co.uk" ) ||
79- process . env . IS_FIREBASE_CLI == "true"
80- ) {
81- return {
82- debug : 1 ,
83- visible : false ,
84- mode : "none" ,
85- variant
86- } ;
87- }
88-
8985 if ( user [ acceptedKey ] ) {
9086 // User has already accepted
9187 return {
@@ -100,7 +96,7 @@ const getPrivacyState = (email, user) => {
10096 const dueBy = user [ dueByKey ] ;
10197 const latestTouch = user [ latestTouchKey ] ;
10298
103- const shouldRetry = shouldRetryPopup ( latestTouch , useUnder13 ) ;
99+ const shouldRetry = shouldRetryPopup ( latestTouch , useUnder13 , guardianEmails ) ;
104100
105101 const delayResponse = {
106102 visible : true ,
0 commit comments