summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2020-12-10 11:46:47 +0100
committerJoas Schilling <coding@schilljs.com>2020-12-10 11:47:05 +0100
commit1e3107771b82640651c478ed990d29aa73089046 (patch)
tree14201e5f3830f360a88e4d14be7e316fc6cfec78
parente747556e33f2b943f32b103652be30ac9ec51f70 (diff)
Do the request via the store
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r--src/components/SettingsDialog/SettingsDialog.vue16
-rw-r--r--src/store/settingsStore.js8
2 files changed, 10 insertions, 14 deletions
diff --git a/src/components/SettingsDialog/SettingsDialog.vue b/src/components/SettingsDialog/SettingsDialog.vue
index d62196a5b..39da96b91 100644
--- a/src/components/SettingsDialog/SettingsDialog.vue
+++ b/src/components/SettingsDialog/SettingsDialog.vue
@@ -106,10 +106,7 @@
<script>
import { getFilePickerBuilder, showError } from '@nextcloud/dialogs'
-import {
- setAttachmentFolder,
- setReadStatusPrivacy,
-} from '../../services/settingsService'
+import { setAttachmentFolder } from '../../services/settingsService'
import { PRIVACY } from '../../constants'
import { subscribe, unsubscribe } from '@nextcloud/event-bus'
import MediaDevicesPreview from '../MediaDevicesPreview'
@@ -191,14 +188,11 @@ export default {
},
async toggleReadStatusPrivacy() {
- let newPrivacy = PRIVACY.PUBLIC
- if (this.readStatusPrivacyIsPublic) {
- newPrivacy = PRIVACY.PRIVATE
- }
-
try {
- this.$store.commit('updateReadStatusPrivacy', newPrivacy)
- await setReadStatusPrivacy(newPrivacy)
+ await this.$store.commit(
+ 'updateReadStatusPrivacy',
+ this.readStatusPrivacyIsPublic ? PRIVACY.PRIVATE : PRIVACY.PUBLIC
+ )
} catch (exception) {
showError(t('spreed', 'Error while setting read status privacy'))
}
diff --git a/src/store/settingsStore.js b/src/store/settingsStore.js
index b8b0ead9e..a8bd04eef 100644
--- a/src/store/settingsStore.js
+++ b/src/store/settingsStore.js
@@ -19,6 +19,7 @@
*/
import { loadState } from '@nextcloud/initial-state'
+import { setReadStatusPrivacy } from '../services/settingsService'
const state = {
readStatusPrivacy: loadState('talk', 'read_status_privacy'),
@@ -45,12 +46,13 @@ const mutations = {
const actions = {
/**
- * Updates the token
+ * Update the read status privacy for the user
*
* @param {object} context default store context;
- * @param {string} privacy The new selected privacy
+ * @param {int} privacy The new selected privacy
*/
- updateReadStatusPrivacy(context, privacy) {
+ async updateReadStatusPrivacy(context, privacy) {
+ await setReadStatusPrivacy(privacy)
context.commit('updateReadStatusPrivacy', privacy)
},
}