From 6a8a96b7481e15c426c2bb2dd175e4d1293522ac Mon Sep 17 00:00:00 2001 From: Harald Bamberger Date: Mon, 6 May 2024 16:04:45 +0200 Subject: [PATCH] fix long lasting request getPrestudents to block browser when timedout once --- public/js/api/studstatus.js | 5 ++++- .../Studierendenantrag/Leitung/Actions/New.js | 21 ++++++++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/public/js/api/studstatus.js b/public/js/api/studstatus.js index d0fc4b074..87d6840b1 100644 --- a/public/js/api/studstatus.js +++ b/public/js/api/studstatus.js @@ -117,7 +117,10 @@ export default { return this.$fhcApi.post( '/api/frontend/v1/studstatus/leitung/getPrestudents', { query }, - { signal } + { + signal: signal, + timeout: 30000 + } ); }, approve(antrag) { diff --git a/public/js/components/Studierendenantrag/Leitung/Actions/New.js b/public/js/components/Studierendenantrag/Leitung/Actions/New.js index 74552f9a3..b566a7d10 100644 --- a/public/js/components/Studierendenantrag/Leitung/Actions/New.js +++ b/public/js/components/Studierendenantrag/Leitung/Actions/New.js @@ -35,8 +35,16 @@ export default { }); }, loadData(evt) { - if (this.abortController) - this.abortController.abort(); + if( evt.query.length < 2 ) + { + return false; + } + + if (this.abortController instanceof AbortController + && this.abortController.signal.aborted === false) + { + this.abortController.abort(); + } this.abortController = new AbortController(); this.$fhcApi.factory @@ -44,7 +52,14 @@ export default { .then(result => { this.data = result.data; }) - .catch(this.$fhcApi.handleSystemError); + .catch(error => { + if (this.abortController instanceof AbortController + && this.abortController.signal.aborted === false) + { + this.abortController.abort(); + } + this.$fhcApi.handleSystemError(error); + }); } }, template: `