fix(capture): Handle when camera isn't allowed

This commit is contained in:
Tixie 2019-04-05 04:03:08 +02:00
parent a3d6e2f4b9
commit d75e606b1e
2 changed files with 11 additions and 12 deletions

View file

@ -98,16 +98,9 @@ export default new Vuex.Store({
? !state.capturing.shouldFaceUser
: state.capturing.shouldFaceUser
try {
commit('startCamera', await getCamera(shouldFaceUser))
if (inverseFacingMode) {
commit('inverseFacingMode')
}
} catch (error) {
console.error(error)
window.alert('You haven\'t allowed to use your camera.\n\nOr maybe your browser is not compatible :(')
commit('updateWelcomed', false)
commit('startCamera', await getCamera(shouldFaceUser))
if (inverseFacingMode) {
commit('inverseFacingMode')
}
},
capture ({ state, commit, dispatch }) {

View file

@ -49,9 +49,15 @@ export default {
await this.$store.dispatch('encode', captureData)
this.$router.push({ name: 'download' })
},
ensureCameraStarted () {
async ensureCameraStarted () {
if (!this.mediaStream) {
this.$store.dispatch('requestCamera', false)
try {
await this.$store.dispatch('requestCamera', false)
} catch (error) {
console.error(error)
window.alert('You haven\'t allowed to use your camera.\n\nOr maybe your browser is not compatible :(')
this.$router.push({ name: 'home' })
}
}
},
handleVisibilityChange (event) {