File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ export declare class StickyPrepopulation {
44 private cookieName ;
55 constructor ( ) ;
66 private shouldRun ;
7- private deleteCookieIfGiftProcessComplete ;
7+ private deleteCookie ;
88 private createCookie ;
99 private applyPrepopulation ;
1010 private getSupporterDetailsFromFields ;
Original file line number Diff line number Diff line change @@ -19,7 +19,14 @@ export class StickyPrepopulation {
1919 return ;
2020 }
2121 this . logger . log ( "StickyPrepopulation initialized" ) ;
22- this . deleteCookieIfGiftProcessComplete ( ) ;
22+ if ( ENGrid . getGiftProcess ( ) ) {
23+ this . deleteCookie ( ) ;
24+ return ;
25+ }
26+ if ( ENGrid . getPageNumber ( ) !== 1 || ! ENGrid . getField ( "supporter.emailAddress" ) ) {
27+ this . logger . log ( "Not on page 1 or email field not present, not creating cookie or applying pre-population." ) ;
28+ return ;
29+ }
2330 this . createCookie ( ) ;
2431 this . applyPrepopulation ( ) ;
2532 }
@@ -44,11 +51,9 @@ export class StickyPrepopulation {
4451 /*
4552 * Delete the cookie if the gift process is complete
4653 */
47- deleteCookieIfGiftProcessComplete ( ) {
48- if ( ENGrid . getGiftProcess ( ) ) {
49- this . logger . log ( "Gift process complete, removing sticky prepopulation cookie if it exists" ) ;
50- cookie . remove ( this . cookieName ) ;
51- }
54+ deleteCookie ( ) {
55+ this . logger . log ( "Gift process complete, removing sticky prepopulation cookie if it exists" ) ;
56+ cookie . remove ( this . cookieName ) ;
5257 }
5358 /*
5459 * Create the cookie if we're coming from a campaign link and supporterId is present
Original file line number Diff line number Diff line change @@ -17,7 +17,14 @@ export class StickyPrepopulation {
1717 return ;
1818 }
1919 this . logger . log ( "StickyPrepopulation initialized" ) ;
20- this . deleteCookieIfGiftProcessComplete ( ) ;
20+ if ( ENGrid . getGiftProcess ( ) ) {
21+ this . deleteCookie ( ) ;
22+ return ;
23+ }
24+ if ( ENGrid . getPageNumber ( ) !== 1 || ! ENGrid . getField ( "supporter.emailAddress" ) ) {
25+ this . logger . log ( "Not on page 1 or email field not present, not creating cookie or applying pre-population." ) ;
26+ return ;
27+ }
2128 this . createCookie ( ) ;
2229 this . applyPrepopulation ( ) ;
2330 }
@@ -43,13 +50,11 @@ export class StickyPrepopulation {
4350 /*
4451 * Delete the cookie if the gift process is complete
4552 */
46- private deleteCookieIfGiftProcessComplete ( ) {
47- if ( ENGrid . getGiftProcess ( ) ) {
48- this . logger . log (
49- "Gift process complete, removing sticky prepopulation cookie if it exists"
50- ) ;
51- cookie . remove ( this . cookieName ) ;
52- }
53+ private deleteCookie ( ) {
54+ this . logger . log (
55+ "Gift process complete, removing sticky prepopulation cookie if it exists"
56+ ) ;
57+ cookie . remove ( this . cookieName ) ;
5358 }
5459
5560 /*
You can’t perform that action at this time.
0 commit comments