Commit d9ff6c56 authored by Gabriel Monnerat's avatar Gabriel Monnerat

erp5_document_scanner: use .push instead of .then, in order to handle promise cancellation

parent 6d233876
......@@ -62,19 +62,29 @@
photoInput = gadget.querySelector(".photoInput");
startbutton = gadget.querySelector(".startbutton");
navigator.mediaDevices.getUserMedia({video: {deviceId: {exact: device_id}}})
.then(gotStream)
.then(function(photoCapabilities) {
return RSVP.Queue()
.push(function() {
return navigator.mediaDevices.getUserMedia({video: {deviceId: {exact: device_id}}});
})
.push(gotStream)
.push(function(photoCapabilities) {
imageWidth = photoCapabilities.imageWidth.max;
imageHeight = photoCapabilities.imageHeight.max;
document.querySelector("textarea[name='field_your_description']").value = "Max => " + imageWidth + "x" + imageHeight;
video.play();
});
})
.push(function(){
/*
XXX remove addEventListener. Instead, use renderJS declareService / onEvent,
which will handle unloading the listener and correctly catching errors
Remove soon
*/
startbutton.addEventListener("click", function(evt){
evt.preventDefault();
takePicture(gadget);
}, false);
});
startbutton.addEventListener("click", function(evt){
evt.preventDefault();
takePicture(gadget);
}, false);
}
function clearphoto() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment