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-01-05 13:47:55 +0300
committerdartcafe <github@dartcafe.de>2021-01-11 00:43:46 +0300
commitc8a5e72cdd7451347011b83a320ec21a8ce927b4 (patch)
tree4b9608a12c521d35612b4d624bad54f628d1bddf /src/js/store
parent2055e7a9f9e0c9c0a3c84840fe88c012d70204ab (diff)
subscription - namespaced and changed loading
Signed-off-by: dartcafe <github@dartcafe.de>
Diffstat (limited to 'src/js/store')
-rw-r--r--src/js/store/modules/subscription.js27
1 files changed, 12 insertions, 15 deletions
diff --git a/src/js/store/modules/subscription.js b/src/js/store/modules/subscription.js
index 64eb3cc0..d4708db0 100644
--- a/src/js/store/modules/subscription.js
+++ b/src/js/store/modules/subscription.js
@@ -32,17 +32,19 @@ const defaultSubscription = () => {
const state = defaultSubscription()
+const namespaced = true
+
const mutations = {
- setSubscription(state, payload) {
- state.subscribed = payload
+ set(state, payload) {
+ state.subscribed = payload.subscribed
},
}
const actions = {
- getSubscription(context) {
+ get(context) {
let endPoint = 'apps/polls'
if (context.rootState.route.name === 'publicVote') {
@@ -55,14 +57,14 @@ const actions = {
return axios.get(generateUrl(endPoint + '/subscription'))
.then((response) => {
- context.commit('setSubscription', response.data.subscribed)
+ context.commit('set', response.data)
})
.catch(() => {
- context.commit('setSubscription', false)
+ context.commit('set', false)
})
},
- writeSubscription(context) {
+ update(context, payload) {
let endPoint = 'apps/polls'
if (context.rootState.route.name === 'publicVote') {
@@ -73,14 +75,9 @@ const actions = {
return
}
- if (state.subscribed) {
- endPoint = endPoint + '/subscribe'
- } else {
- endPoint = endPoint + '/unsubscribe'
- }
-
- return axios.put(generateUrl(endPoint))
- .then(() => {
+ return axios.put(generateUrl(endPoint + (payload ? '/subscribe' : '/unsubscribe')))
+ .then((response) => {
+ context.commit('set', response.data)
})
.catch((error) => {
console.error(error.response)
@@ -88,4 +85,4 @@ const actions = {
},
}
-export default { state, mutations, actions }
+export default { namespaced, state, mutations, actions }