@@ -217,8 +217,7 @@ const apiUserFields = [
217217const fetchHandler = {
218218 handler (val , oldVal ) {
219219 if (val !== oldVal) {
220- this .currentPage = 1
221- this .fetchUsers ()
220+ this .queueUsersFetch ()
222221 }
223222 },
224223 deep: true
@@ -242,15 +241,17 @@ export default {
242241 locationOptions: null ,
243242 searchDebounce: null ,
244243 localSearchFilter: ' ' ,
245- pendingSearchFetch: false ,
244+ pendingUsersFetch: false ,
245+ pendingUsersFetchResetPage: false ,
246+ usersFetchRequest: 0 ,
246247 countries: require (' country-list' )()
247248 }
248249 },
249250 watch: {
250251 currentPage: {
251252 handler (val , oldVal ) {
252253 if (val !== oldVal) {
253- this .fetchUsers ()
254+ this .queueCurrentPageFetch ()
254255 }
255256 },
256257 deep: true
@@ -287,7 +288,7 @@ export default {
287288 handler (val , oldVal ) {
288289 if (! this .apiUsers ) {
289290 this .setLocalStorage ()
290- this .fetchUsers ()
291+ this .queueUsersFetch ()
291292 }
292293 },
293294 deep: true
@@ -359,21 +360,29 @@ export default {
359360 return
360361 }
361362 this .searchFilter = search
363+ this .queueUsersFetch ()
364+ },
365+ queueUsersFetch (resetPage = true ) {
362366 if (this .fetchingUsers ) {
363- this .pendingSearchFetch = true
367+ this .pendingUsersFetch = true
368+ this .pendingUsersFetchResetPage = this .pendingUsersFetchResetPage || resetPage
364369 return
365370 }
366- if (this .currentPage !== 1 ) {
371+ if (resetPage && this .currentPage !== 1 ) {
367372 this .currentPage = 1
368373 } else {
369374 this .fetchUsers ()
370375 }
371376 },
377+ queueCurrentPageFetch () {
378+ this .queueUsersFetch (false )
379+ },
372380 async fetchUsers () {
373381 const search = this .searchFilter ? this .searchFilter .trim () : ' '
374382 if (search .length > 0 && search .length < 3 ) {
375383 return
376384 }
385+ const requestId = ++ this .usersFetchRequest
377386 this .fetchingUsers = true
378387 if (this .rolesEmpty ) {
379388 await this .fetchRoles ()
@@ -410,10 +419,15 @@ export default {
410419 this .$noty .error (this .$t (' error_alert_text' ))
411420 }
412421
422+ if (requestId !== this .usersFetchRequest ) {
423+ return
424+ }
413425 this .fetchingUsers = false
414- if (this .pendingSearchFetch ) {
415- this .pendingSearchFetch = false
416- this .queueSearchFetch ()
426+ if (this .pendingUsersFetch ) {
427+ const resetPage = this .pendingUsersFetchResetPage
428+ this .pendingUsersFetch = false
429+ this .pendingUsersFetchResetPage = false
430+ this .queueUsersFetch (resetPage)
417431 }
418432 },
419433 async fetchRoles () {
0 commit comments