Change image loading to promise (#25)
This PR makes the detection page image loading a promise for better loading success and error handling. Signed-off-by: Justin Georgi <justin.georgi@gmail.com> Reviewed-on: Georgi_Lab/ALVINN_f7#25
This commit is contained in:
@@ -314,15 +314,23 @@
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
getImage () {
|
getImage () {
|
||||||
|
var self = this
|
||||||
const searchImage = this.$refs.image_chooser.files[0]
|
const searchImage = this.$refs.image_chooser.files[0]
|
||||||
//Promise goes here?
|
let loadImage =new Promise((resolve, reject) => {
|
||||||
this.imageView = URL.createObjectURL(searchImage)
|
this.imageView = URL.createObjectURL(searchImage)
|
||||||
this.reader.readAsDataURL(searchImage)
|
this.reader.readAsDataURL(searchImage)
|
||||||
this.imageLoaded = true
|
resolve()
|
||||||
this.resultData = {}
|
})
|
||||||
this.selectedChip = -1
|
loadImage.then(() => {
|
||||||
const box = this.$refs.structure_box
|
this.imageLoaded = true
|
||||||
box.style.display = 'none'
|
this.resultData = {}
|
||||||
|
this.selectedChip = -1
|
||||||
|
const box = this.$refs.structure_box
|
||||||
|
box.style.display = 'none'
|
||||||
|
}).catch((e) => {
|
||||||
|
console.log(e.message)
|
||||||
|
f7.dialog.alert('Error loading image')
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user