Commit 25ecc376 authored by Romain Courteaud's avatar Romain Courteaud

erp5_document_scanner: samsung browser randomize the device ID

Try to get the cropper options from previous device ID
parent e9938482
...@@ -829,7 +829,38 @@ ...@@ -829,7 +829,38 @@
return getPreferredDevice(gadget) return getPreferredDevice(gadget)
.push(function (preferred_device_id) { .push(function (preferred_device_id) {
return selectMediaDevice(camera_list, preferred_device_id, false); return RSVP.all([
selectMediaDevice(camera_list, preferred_device_id, false),
preferred_device_id
]);
})
.push(function (result_list) {
var device_id = result_list[0],
preferred_device_id = result_list[1];
if (device_id !== preferred_device_id) {
// Previous camera used in the same session was not found
// Samsung browser seems to randomize the device ID every time
// it is accessed
// Duplicate previous crop options
return gadget.session_storage_jio.get(CROPPER_DATA_JIO_KEY + preferred_device_id)
.push(function (data) {
return gadget.session_storage_jio.put(
CROPPER_DATA_JIO_KEY + device_id,
data
);
}, function (error) {
if ((error instanceof jIO.util.jIOError) &&
(error.status_code === 404)) {
// If no previous crop data found, nothing to do
return;
}
throw error;
})
.push(function () {
return device_id;
});
}
return device_id;
}) })
.push(function (device_id) { .push(function (device_id) {
if (camera_list.indexOf(device_id) === -1) { if (camera_list.indexOf(device_id) === -1) {
......
...@@ -244,7 +244,7 @@ ...@@ -244,7 +244,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>986.29418.46329.12509</string> </value> <value> <string>986.29479.21271.57395</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -262,7 +262,7 @@ ...@@ -262,7 +262,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1599470361.92</float> <float>1599473730.39</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
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