@@ -18,10 +18,6 @@ var gpfupInstances = Object.keys(window).filter(function (key) {
1818 return key . startsWith ( 'GPFUP_' + formId + '_' ) ;
1919} ) ;
2020
21- if ( ! gpfupInstances . length ) {
22- return ;
23- }
24-
2521// Build reverse lookup: uploadFieldID => associated countFieldIDs
2622var uploadToCountMap = { } ;
2723Object . entries ( countMapping ) . forEach ( function ( [ countFieldID , uploadFieldIDs ] ) {
@@ -47,20 +43,22 @@ function updateAllCountFields() {
4743 } ) ;
4844}
4945
50- // Subscribe to relevant GPFUP fields
51- gpfupInstances . forEach ( function ( key ) {
52- var parts = key . split ( '_' ) ;
53- var fieldID = parseInt ( parts [ 2 ] ) ; // GPFUP_formId_fieldId
54- var store = window [ key ] . $store ;
46+ if ( gpfupInstances . length ) {
47+ // Subscribe to relevant GPFUP fields
48+ gpfupInstances . forEach ( function ( key ) {
49+ var parts = key . split ( '_' ) ;
50+ var fieldID = parseInt ( parts [ 2 ] ) ; // GPFUP_formId_fieldId
51+ var store = window [ key ] . $store ;
5552
56- if ( uploadToCountMap [ fieldID ] ) {
57- store . subscribe ( function ( mutation , state ) {
58- if ( mutation . type === 'SET_FILES' ) {
59- updateAllCountFields ( ) ;
60- }
61- } ) ;
62- }
63- } ) ;
53+ if ( uploadToCountMap [ fieldID ] ) {
54+ store . subscribe ( function ( mutation , state ) {
55+ if ( mutation . type === 'SET_FILES' ) {
56+ updateAllCountFields ( ) ;
57+ }
58+ } ) ;
59+ }
60+ } ) ;
61+ }
6462
6563// Initial count on load
6664updateAllCountFields ( ) ;
0 commit comments