Browse Source

Merge pull request #2477 from nextcloud/bugfix/noissue/error-handling

John's comments
pull/2480/head
marco 6 years ago
committed by GitHub
parent
commit
ef62ac0ebe
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 58
      src/components/Sidebar/Participants/ParticipantsTab.vue
  2. 3
      src/components/Sidebar/Sidebar.vue
  3. 10
      src/store/participantsStore.js

58
src/components/Sidebar/Participants/ParticipantsTab.vue

@ -166,34 +166,54 @@ export default {
}, 250),
async fetchSearchResults() {
const response = await searchPossibleConversations(this.searchText)
this.searchResults = response.data.ocs.data
this.getParticipants()
this.contactsLoading = false
try {
const response = await searchPossibleConversations(this.searchText)
this.searchResults = response.data.ocs.data
this.getParticipants()
this.contactsLoading = false
} catch (exeption) {
console.error(exeption)
OCP.Toast.error(t('spreed', 'An error occurred while performing the search'))
}
},
async toggleGuests() {
await this.$store.dispatch('toggleGuests', {
token: this.token,
allowGuests: this.conversation.type !== CONVERSATION.TYPE.PUBLIC,
})
try {
await this.$store.dispatch('toggleGuests', {
token: this.token,
allowGuests: this.conversation.type !== CONVERSATION.TYPE.PUBLIC,
})
} catch (exeption) {
console.error(exeption)
OCP.Toast.error(t('spreed', 'An error occurred while toggling guests'))
}
},
async toggleLobby() {
await this.$store.dispatch('toggleLobby', {
token: this.token,
enableLobby: this.conversation.lobbyState !== WEBINAR.LOBBY.NON_MODERATORS,
})
try {
await this.$store.dispatch('toggleLobby', {
token: this.token,
enableLobby: this.conversation.lobbyState !== WEBINAR.LOBBY.NON_MODERATORS,
})
} catch (exeption) {
console.error(exeption)
OCP.Toast.error(t('spreed', 'An error occurred while toggling the lobby'))
}
},
async getParticipants() {
const participants = await fetchParticipants(this.token)
this.$store.dispatch('purgeParticipantsStore', this.token)
participants.data.ocs.data.forEach(participant => {
this.$store.dispatch('addParticipant', {
token: this.token,
participant: participant,
try {
const participants = await fetchParticipants(this.token)
this.$store.dispatch('purgeParticipantsStore', this.token)
participants.data.ocs.data.forEach(participant => {
this.$store.dispatch('addParticipant', {
token: this.token,
participant,
})
})
})
} catch (exeption) {
console.error(exeption)
OCP.Toast.error(t('spreed', 'An error occurred while fetching the participants'))
}
},
},
}

3
src/components/Sidebar/Sidebar.vue

@ -126,7 +126,8 @@ export default {
},
displaySearchBox() {
return this.conversation.type === CONVERSATION.TYPE.GROUP || this.conversation.type === CONVERSATION.TYPE.PUBLIC
return this.conversation.type === CONVERSATION.TYPE.GROUP
|| this.conversation.type === CONVERSATION.TYPE.PUBLIC
},
isSearching() {
return this.searchText !== ''

10
src/store/participantsStore.js

@ -74,17 +74,23 @@ const mutations = {
addParticipant(state, { token, participant }) {
if (!state.participants[token]) {
Vue.set(state.participants, token, [])
} else {
console.error('Error while adding the participant')
}
state.participants[token].push(participant)
},
updateParticipant(state, { token, index, updatedData }) {
if (state.participants[token] && state.participants[token][index]) {
state.participants[token][index] = Object.assign(state.participants[token][index], updatedData)
} else {
console.error('Error while updating the participant')
}
},
deleteParticipant(state, { token, index }) {
if (state.participants[token] && state.participants[token][index]) {
Vue.delete(state.participants[token], index)
} else {
console.error(`The conversation you are trying to purge doesn't exist`)
}
},
/**
@ -95,7 +101,9 @@ const mutations = {
purgeParticipantsStore(state, token) {
if (state.participants[token]) {
Vue.delete(state.participants, token)
} else console.debug("The conversation you are trying to purge doesn't exist")
} else {
console.error('Error while purging the participants')
}
},
}

Loading…
Cancel
Save