Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/polls.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordartcafe <github@dartcafe.de>2022-11-10 01:06:51 +0300
committerdartcafe <github@dartcafe.de>2022-11-10 01:06:51 +0300
commit20cd87e3fec2feb57c23834a6804bfcb162756c0 (patch)
tree7b8b8ca0ab2944ccec21f1b1e9c578c9889fb49c /src/js/components
parent97509e53a1a487ae3985170061d26df9287b551b (diff)
added error handling on canceled requests
Signed-off-by: dartcafe <github@dartcafe.de>
Diffstat (limited to 'src/js/components')
-rw-r--r--src/js/components/Actions/ActionSendConfirmedOptions.vue7
-rw-r--r--src/js/components/Calendar/CalendarPeek.vue1
-rw-r--r--src/js/components/Export/ExportPoll.vue14
-rw-r--r--src/js/components/Poll/PublicRegisterModal.vue94
-rw-r--r--src/js/components/User/UserMenu.vue3
5 files changed, 77 insertions, 42 deletions
diff --git a/src/js/components/Actions/ActionSendConfirmedOptions.vue b/src/js/components/Actions/ActionSendConfirmedOptions.vue
index b161c73c..76a105a3 100644
--- a/src/js/components/Actions/ActionSendConfirmedOptions.vue
+++ b/src/js/components/Actions/ActionSendConfirmedOptions.vue
@@ -76,7 +76,12 @@ export default {
methods: {
async clickAction() {
- this.confirmations = await PollsAPI.sendConfirmation(this.$route.params.id)
+ try {
+ this.confirmations = await PollsAPI.sendConfirmation(this.$route.params.id)
+ } catch (e) {
+ if (e?.code === 'ERR_CANCELED') return
+ }
+
this.headerCaption = t('polls', 'Confirmations processed')
this.confirmations.sent.forEach((confirmation) => {
showSuccess(t('polls', `Confirmation sent to ${confirmation}`))
diff --git a/src/js/components/Calendar/CalendarPeek.vue b/src/js/components/Calendar/CalendarPeek.vue
index f2a7ea88..474ba2f3 100644
--- a/src/js/components/Calendar/CalendarPeek.vue
+++ b/src/js/components/Calendar/CalendarPeek.vue
@@ -119,6 +119,7 @@ export default {
const response = CalendarAPI.getEvents(this.option.pollId)
this.events = response.data.events
} catch (e) {
+ if (e?.code === 'ERR_CANCELED') return
if (e.message === 'Network Error') {
showError(t('polls', 'Got a network error while checking calendar events.'))
}
diff --git a/src/js/components/Export/ExportPoll.vue b/src/js/components/Export/ExportPoll.vue
index 3e5254d8..7d0ee8fa 100644
--- a/src/js/components/Export/ExportPoll.vue
+++ b/src/js/components/Export/ExportPoll.vue
@@ -126,11 +126,15 @@ export default {
}
if (this.isOwner) {
- participantsHeader.push(t('polls', 'Email address'))
- fromHeader.push('')
- toHeader.push('')
- const response = await PollsAPI.getParticipantsEmailAddresses(this.$route.params.id)
- this.emailAddresses = response.data
+ try {
+ participantsHeader.push(t('polls', 'Email address'))
+ fromHeader.push('')
+ toHeader.push('')
+ const response = await PollsAPI.getParticipantsEmailAddresses(this.$route.params.id)
+ this.emailAddresses = response.data
+ } catch (error) {
+ if (error.name === 'CanceledError') return
+ }
}
if (this.poll.type === 'textPoll') {
diff --git a/src/js/components/Poll/PublicRegisterModal.vue b/src/js/components/Poll/PublicRegisterModal.vue
index 57cc3ac6..5a5d1e6d 100644
--- a/src/js/components/Poll/PublicRegisterModal.vue
+++ b/src/js/components/Poll/PublicRegisterModal.vue
@@ -104,6 +104,8 @@ import { ValidatorAPI } from '../../Api/validators.js'
import { PublicAPI } from '../../Api/public.js'
import { setCookie } from '../../helpers/cookieHelper.js'
+const COOKIE_LIFETIME = 30
+
export default {
name: 'PublicRegisterModal',
@@ -288,8 +290,13 @@ export default {
try {
await ValidatorAPI.validateName(this.$route.params.token, this.userName)
this.status.userName = 'valid'
- } catch {
- this.status.userName = 'invalid'
+ } catch (e) {
+ if (e?.code === 'ERR_CANCELED') return
+ if (e?.code === 'ERR_BAD_REQUEST') {
+ this.status.userName = 'invalid'
+ return
+ }
+ throw e
}
}, 500),
@@ -298,46 +305,63 @@ export default {
try {
await ValidatorAPI.validateEmailAddress(this.emailAddress)
this.status.email = 'valid'
- } catch {
- this.status.email = 'valid'
+ } catch (e) {
+ if (e?.code === 'ERR_CANCELED') return
+ if (e?.code === 'ERR_BAD_REQUEST') {
+ this.status.email = 'invalid'
+ return
+ }
+ throw e
}
}, 500),
- async submitRegistration() {
- if (this.registrationIsValid) {
- try {
- const response = await PublicAPI.register(
- this.$route.params.token,
- this.userName,
- this.emailAddress,
- )
-
- if (this.saveCookie && this.$route.params.type === 'public') {
- const cookieExpiration = (30 * 24 * 60 * 1000)
- setCookie(this.$route.params.token, response.data.share.token, cookieExpiration)
- }
+ updateCookie(value) {
+ const cookieExpiration = (COOKIE_LIFETIME * 24 * 60 * 1000)
+ setCookie(this.$route.params.token, value, cookieExpiration)
+ },
- if (this.$route.params.token === response.data.share.token) {
- // if share was not a public share, but a personal share
- // (i.e. email shares allow to change personal data by fist entering of the poll),
- // just load the poll
- this.$store.dispatch({ type: 'poll/get' })
- this.closeModal()
- } else {
- // in case of a public share, redirect to the generated share
- this.redirecting = true
- this.$router.replace({ name: 'publicVote', params: { token: response.data.share.token } })
- this.closeModal()
- }
+ routeToPersonalShare(token) {
+ if (this.$route.params.token === token) {
+ // if share was not a public share, but a personal share
+ // (i.e. email shares allow to change personal data by fist entering of the poll),
+ // just load the poll
+ this.$store.dispatch({ type: 'poll/get' })
+ this.closeModal()
+ } else {
+ // in case of a public share, redirect to the generated share
+ this.redirecting = true
+ this.$router.replace({ name: 'publicVote', params: { token } })
+ this.closeModal()
+ }
- // TODO: Is that correct, is this possible in any way?
- if (this.share.emailAddress && !this.share.invitationSent) {
- showError(t('polls', 'Email could not be sent to {emailAddress}', { emailAddress: this.share.emailAddress }))
- }
- } catch (e) {
- showError(t('polls', 'Error registering to poll', { error: e.response }))
+ },
+
+ async submitRegistration() {
+ if (!this.registrationIsValid) {
+ return
+ }
+
+ try {
+ const response = await PublicAPI.register(
+ this.$route.params.token,
+ this.userName,
+ this.emailAddress,
+ )
+
+ if (this.saveCookie && this.$route.params.type === 'public') {
+ this.updateCookie(response.data.share.token)
}
+ this.routeToPersonalShare(response.data.share.token)
+
+ // TODO: Is that correct, is this possible in any way?
+ if (this.share.emailAddress && !this.share.invitationSent) {
+ showError(t('polls', 'Email could not be sent to {emailAddress}', { emailAddress: this.share.emailAddress }))
+ }
+ } catch (e) {
+ if (e?.code === 'ERR_CANCELED') return
+ showError(t('polls', 'Error registering to poll', { error: e.response }))
+ throw e
}
},
},
diff --git a/src/js/components/User/UserMenu.vue b/src/js/components/User/UserMenu.vue
index 605d7f65..234198d5 100644
--- a/src/js/components/User/UserMenu.vue
+++ b/src/js/components/User/UserMenu.vue
@@ -334,7 +334,8 @@ export default {
const response = await PollsAPI.getParticipantsEmailAddresses(this.$route.params.id)
await navigator.clipboard.writeText(response.data.map((item) => item.combined))
showSuccess(t('polls', 'Link copied to clipboard'))
- } catch {
+ } catch (e) {
+ if (e?.code === 'ERR_CANCELED') return
showError(t('polls', 'Error while copying link to clipboard'))
}
},