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>2021-02-27 10:43:41 +0300
committerdartcafe <github@dartcafe.de>2021-02-27 10:43:41 +0300
commitcc2065aa69630cba75793e4b55544ed41ca33e99 (patch)
tree0e5d863eec22c124c18cae76a332193ab43ef9d3 /src/js/views
parent2c68439975374dcd2d6c90a56818fa1b861ad6f1 (diff)
promise.all for async loadings
Signed-off-by: dartcafe <github@dartcafe.de>
Diffstat (limited to 'src/js/views')
-rw-r--r--src/js/views/Vote.vue24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/js/views/Vote.vue b/src/js/views/Vote.vue
index 4aabcb51..0be1e2ae 100644
--- a/src/js/views/Vote.vue
+++ b/src/js/views/Vote.vue
@@ -374,33 +374,53 @@ export default {
params: { offset: this.lastUpdated },
cancelToken: this.cancelToken.token,
})
+ const dispatches = []
+
console.debug('polls', 'update detected', response.data.updates)
+
response.data.updates.forEach((item) => {
this.lastUpdated = (item.updated > this.lastUpdated) ? item.updated : this.lastUpdated
if (item.table === 'polls') {
- this.$store.dispatch('poll/get')
+ dispatches.push('poll/get')
+ // this.$store.dispatch('poll/get')
} else {
- this.$store.dispatch('poll/' + item.table + '/list')
+ dispatches.push('poll/' + item.table + '/list')
+ // this.$store.dispatch('poll/' + item.table + '/list')
}
})
+ const requests = dispatches.map(dispatches => this.$store.dispatch(dispatches))
+ await Promise.all(requests)
+
this.watching = true
+
} catch (error) {
this.watching = false
+
if (axios.isCancel(error)) {
console.debug('Watch canceld')
} else if (error.response) {
+
if (error.response.status === 304) {
+
this.watching = true
+
} else if (error.response.status === 503) {
+
console.debug('Server not available, reconnect watch in 30 sec')
+
await new Promise(resolve => setTimeout(resolve, 30000))
this.watching = true
+
} else {
+
console.error('Unhandled error watching polls', error)
+
}
} else if (error.request) {
+
console.debug('Watch aborted')
this.watching = true
+
}
}
}