Browse Source

Merge pull request #5519 from nextcloud/bugfix/noid/sound-setting-for-users

Fix loading the correct sound setting for users
pull/5520/head
Vincent Petry 5 years ago
committed by GitHub
parent
commit
ba4277e9ab
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 48
      src/components/SettingsDialog/SettingsDialog.vue
  2. 4
      src/store/fileUploadStore.js
  3. 19
      src/store/soundsStore.js

48
src/components/SettingsDialog/SettingsDialog.vue

@ -58,11 +58,11 @@
:title="t('spreed', 'Sounds')"
class="app-settings-section">
<input id="play_sounds"
v-model="playSounds"
:checked="readStatusPrivacyIsPublic"
:disabled="privacyLoading"
:checked="playSounds"
:disabled="playSoundsLoading"
type="checkbox"
class="checkbox">
class="checkbox"
@change="togglePlaySounds">
<label for="play_sounds">{{ t('settings', 'Play sounds when participants join a call or leave it') }}</label>
<em>{{ t('settings', 'Sounds can currently not be played in Safari browser and iPad and iPhone devices due to technical restrictions by the manufacturer.') }}</em>
</AppSettingsSection>
@ -129,10 +129,6 @@
<script>
import { getFilePickerBuilder, showError, showSuccess } from '@nextcloud/dialogs'
import {
setAttachmentFolder,
setPlaySounds,
} from '../../services/settingsService'
import { PRIVACY } from '../../constants'
import { subscribe, unsubscribe } from '@nextcloud/event-bus'
import MediaDevicesPreview from '../MediaDevicesPreview'
@ -153,23 +149,13 @@ export default {
showSettings: false,
attachmentFolderLoading: true,
privacyLoading: false,
playSoundsLoading: false,
}
},
computed: {
// Local settings
playSounds: {
get() {
return this.$store.getters.playSounds
},
set(status) {
this.$store.commit('setPlaySounds', status)
try {
setPlaySounds(status)
} catch (e) {
showError(t('spreed', 'Failed to save sounds setting'))
}
},
playSounds() {
return this.$store.getters.playSounds
},
attachmentFolder() {
@ -216,14 +202,11 @@ export default {
throw new Error(t('spreed', 'Invalid path selected'))
}
const oldFolder = this.attachmentFolder
this.attachmentFolderLoading = true
try {
this.$store.commit('setAttachmentFolder', path)
await setAttachmentFolder(path)
this.$store.dispatch('setAttachmentFolder', path)
} catch (exception) {
showError(t('spreed', 'Error while setting attachment folder'))
this.$store.commit('setAttachmentFolder', oldFolder)
}
this.attachmentFolderLoading = false
})
@ -243,6 +226,21 @@ export default {
this.privacyLoading = false
},
async togglePlaySounds() {
this.playSoundsLoading = true
try {
try {
await this.$store.dispatch('setPlaySounds', status)
} catch (e) {
showError(t('spreed', 'Failed to save sounds setting'))
}
showSuccess(t('spreed', 'Sounds setting saved'))
} catch (exception) {
showError(t('spreed', 'Error while saving sounds setting'))
}
this.playSoundsLoading = false
},
handleShowSettings() {
this.showSettings = true
},

4
src/store/fileUploadStore.js

@ -28,6 +28,7 @@ import { findUniquePath } from '../utils/fileUpload'
import createTemporaryMessage from '../utils/temporaryMessage'
import { EventBus } from '../services/EventBus'
import { shareFile } from '../services/filesSharingServices'
import { setAttachmentFolder } from '../services/settingsService'
const state = {
attachmentFolder: fromStateOr('spreed', 'attachment_folder', ''),
@ -325,7 +326,8 @@ const actions = {
* @param {object} context default store context;
* @param {string} attachmentFolder Folder to store new attachments in
*/
setAttachmentFolder(context, attachmentFolder) {
async setAttachmentFolder(context, attachmentFolder) {
await setAttachmentFolder(attachmentFolder)
context.commit('setAttachmentFolder', attachmentFolder)
},

19
src/store/soundsStore.js

@ -22,8 +22,10 @@
import fromStateOr from './helper'
import BrowserStorage from '../services/BrowserStorage'
import { setPlaySounds } from '../services/settingsService'
const state = {
userId: undefined,
playSoundsUser: fromStateOr('spreed', 'play_sounds', false),
playSoundsGuest: BrowserStorage.getItem('play_sounds') !== 'no',
}
@ -48,16 +50,31 @@ const mutations = {
state.playSoundsUser = enabled
state.playSoundsGuest = enabled
},
setUserId(state, userId) {
state.userId = userId
},
}
const actions = {
/**
* @param {object} context default store context;
* @param {object} user A NextcloudUser object as returned by @nextcloud/auth
* @param {string} user.uid The user id of the user
*/
setCurrentUser(context, user) {
context.commit('setUserId', user.uid)
},
/**
* Set the actor from the current user
*
* @param {object} context default store context;
* @param {boolean} enabled Whether sounds should be played
*/
setPlaySounds({ commit }, enabled) {
async setPlaySounds({ commit }, enabled) {
await setPlaySounds(status)
commit('setPlaySounds', enabled)
},
}

Loading…
Cancel
Save