summaryrefslogtreecommitdiffstats
path: root/src/store
diff options
context:
space:
mode:
authorJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2021-04-27 19:38:41 +0200
committerJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2021-05-30 10:28:57 +0200
commit9facd8fbf3621df573f0e56e54da0612482c3c62 (patch)
treef0130a5354a36f312444e017731bb2951f10d17a /src/store
parentbb5f38e9231b659f348fbd83422af0d65194037b (diff)
Refactor circle actions
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'src/store')
-rw-r--r--src/store/circles.js24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/store/circles.js b/src/store/circles.js
index bd9efaba..72d8cb60 100644
--- a/src/store/circles.js
+++ b/src/store/circles.js
@@ -23,7 +23,7 @@
import { showError } from '@nextcloud/dialogs'
import Vue from 'vue'
-import { createCircle, deleteCircle, deleteMember, getCircleMembers, getCircles, leaveCircle, addMembers } from '../services/circles.ts'
+import { createCircle, deleteCircle, deleteMember, getCircleMembers, getCircle, getCircles, leaveCircle, addMembers } from '../services/circles.ts'
import Member from '../models/member.ts'
import Circle from '../models/circle.ts'
@@ -102,7 +102,6 @@ const getters = {
}
const actions = {
-
/**
* Retrieve and commit circles
*
@@ -132,6 +131,27 @@ const actions = {
},
/**
+ * Retrieve and commit circles
+ *
+ * @param {Object} context the store mutations
+ * @param {string} circleId the circle id
+ * @returns {Object[]} the circles
+ */
+ async getCircle(context, circleId) {
+ const circle = await getCircle(circleId)
+ console.debug('Retrieved 1 circle', circle)
+
+ try {
+ const newCircle = new Circle(circle)
+ context.commit('addCircle', newCircle)
+ } catch (error) {
+ console.error('This circle failed to be processed', circle, error)
+ }
+
+ return circle
+ },
+
+ /**
* Retrieve and commit circle members
*
* @param {Object} context the store mutations