Skip to content

Commit

Permalink
Additional backwards conversion for newer data formats (qzind#951)
Browse files Browse the repository at this point in the history
Additional conversion for newer data formats
Closes qzind#665

Co-authored-by: Tres Finocchiaro <[email protected]>
Co-authored-by: klabarge <[email protected]>
  • Loading branch information
3 people authored Apr 6, 2022
1 parent 25f7576 commit 875c703
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions js/qz-tray.js
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,13 @@ var qz = (function() {
}
},

/** Stub for rejecting with an Error from withing a Promise */
reject: function(error) {
return _qz.tools.promise(function(resolve, reject) {
reject(error);
});
},

stringify: function(object) {
//old versions of prototype affect stringify
var pjson = Array.prototype.toJSON;
Expand Down Expand Up @@ -2115,6 +2122,15 @@ var qz = (function() {
if (deviceInfo.data.type && deviceInfo.data.type.toUpperCase() == "FILE") {
deviceInfo.data.data = _qz.tools.absolute(deviceInfo.data.data);
}
} else {
if (typeof deviceInfo.data === 'object') {
if (deviceInfo.data.type.toUpperCase() !== "PLAIN"
|| typeof deviceInfo.data.data !== "string") {
return _qz.tools.reject(new Error("Data format is not supported with connected QZ Tray version " + _qz.websocket.connection.version));
}

deviceInfo.data = deviceInfo.data.data;
}
}

return _qz.websocket.dataPromise('hid.sendData', deviceInfo);
Expand Down

0 comments on commit 875c703

Please sign in to comment.