@@ -88,33 +88,89 @@ const App = () => {
8888 if ( location . pathname === "/earn/my-gigs" && isLoggedIn ) {
8989 if ( ! location . search ) {
9090 store . dispatch ( actions . filter . updateGigFilter ( initialGigFilter ) ) ;
91-
91+ const cachedGigs = store . getState ( ) . myGigs [ initialGigFilter . status ] ;
92+ if ( cachedGigs . myGigs && cachedGigs . myGigs . length !== 0 ) {
93+ return ;
94+ }
9295 store . dispatch (
93- actions . myGigs . getMyGigs (
96+ actions . myGigs . getMyOpenGigs (
9497 constants . GIGS_FILTER_STATUSES_PARAM [ initialGigFilter . status ]
9598 )
9699 ) ;
97100 return ;
98101 }
99102 const params = utils . url . parseUrlQuery ( location . search ) ;
100103 if ( _ . keys ( params ) . length == 1 && params . externalId ) {
104+ store . dispatch ( actions . myGigs . startCheckingGigs ( params . externalId ) ) ;
101105 return ;
102106 }
107+ const s =
108+ _ . values ( constants . GIGS_FILTER_STATUSES ) . indexOf ( params . status ) >= 0
109+ ? params . status
110+ : null ;
103111 const updatedGigFilter = {
104- status : params . status || "Open Applications" ,
112+ status : s || "Open Applications" ,
105113 } ;
106114 const currentGig = store . getState ( ) . filter . gig ;
107115 const diff = ! _ . isEqual ( updatedGigFilter , currentGig ) ;
108116 if ( diff ) {
109117 store . dispatch ( actions . filter . updateGigFilter ( updatedGigFilter ) ) ;
110118 }
111- getDataDebounced . current ( ( ) =>
112- store . dispatch (
113- actions . myGigs . getMyGigs (
114- constants . GIGS_FILTER_STATUSES_PARAM [ updatedGigFilter . status ]
115- )
116- )
117- ) ;
119+ if ( updatedGigFilter . status !== initialGigFilter . status ) {
120+ // preload the open application first page data.
121+ const cachedOpenGigs = store . getState ( ) . myGigs [ initialGigFilter . status ] ;
122+ if ( ! cachedOpenGigs . myGigs ) {
123+ store . dispatch (
124+ actions . myGigs . getMyOpenGigs (
125+ constants . GIGS_FILTER_STATUSES_PARAM [ initialGigFilter . status ]
126+ )
127+ ) ;
128+ }
129+ }
130+ const cachedGigs = store . getState ( ) . myGigs [ updatedGigFilter . status ] ;
131+ if ( cachedGigs . myGigs ) {
132+ return ;
133+ }
134+ getDataDebounced . current ( ( ) => {
135+ if (
136+ updatedGigFilter . status == constants . GIGS_FILTER_STATUSES . ACTIVE_JOBS
137+ ) {
138+ store . dispatch (
139+ actions . myGigs . getMyActiveGigs (
140+ constants . GIGS_FILTER_STATUSES_PARAM [ updatedGigFilter . status ]
141+ )
142+ ) ;
143+ }
144+ if (
145+ updatedGigFilter . status == constants . GIGS_FILTER_STATUSES . OPEN_JOBS
146+ ) {
147+ store . dispatch (
148+ actions . myGigs . getMyOpenGigs (
149+ constants . GIGS_FILTER_STATUSES_PARAM [ updatedGigFilter . status ]
150+ )
151+ ) ;
152+ }
153+ if (
154+ updatedGigFilter . status ==
155+ constants . GIGS_FILTER_STATUSES . COMPLETED_JOBS
156+ ) {
157+ store . dispatch (
158+ actions . myGigs . getMyCompletedGigs (
159+ constants . GIGS_FILTER_STATUSES_PARAM [ updatedGigFilter . status ]
160+ )
161+ ) ;
162+ }
163+ if (
164+ updatedGigFilter . status ==
165+ constants . GIGS_FILTER_STATUSES . ARCHIVED_JOBS
166+ ) {
167+ store . dispatch (
168+ actions . myGigs . getMyArchivedGigs (
169+ constants . GIGS_FILTER_STATUSES_PARAM [ updatedGigFilter . status ]
170+ )
171+ ) ;
172+ }
173+ } ) ;
118174 }
119175 } , [ location , isLoggedIn ] ) ;
120176
0 commit comments