Exchanges await with promise chain, somehow that does not cause msg loading to fail
@@ -929,15 +929,16 @@ won.DomainObjectFactory.prototype = {
jsonLdToWonDomainObjects: function(/*jsonLdContent*/) {},
};
-won.wonMessageFromJsonLd = async function(wonMessageAsJsonLD) {
- const expandedJsonLd = await jsonld.promises.expand(wonMessageAsJsonLD);
+won.wonMessageFromJsonLd = function(wonMessageAsJsonLD) {
+ return jsonld.promises.expand(wonMessageAsJsonLD).then(expandedJsonLd => {
const wonMessage = new WonMessage(expandedJsonLd);
- await wonMessage.frameInPromise();
- await wonMessage.generateContentGraphTrig();
- await wonMessage.generateCompactedFramedMessage();
- await wonMessage.generateContainedForwardedWonMessages();
-
+ return wonMessage
+ .frameInPromise()
+ .then(() => wonMessage.generateContentGraphTrig())
+ .then(() => wonMessage.generateCompactedFramedMessage())
+ .then(() => wonMessage.generateContainedForwardedWonMessages())
+ .then(() => {
if (wonMessage.hasParseErrors() && !wonMessage.isResponse()) {
console.warn(
"wonMessage<",
@@ -958,7 +959,9 @@ won.wonMessageFromJsonLd = async function(wonMessageAsJsonLD) {
"> contains forwardedMessages wonMessage: ",
wonMessage
);
- wonMessage.getContainedForwardedWonMessages().map(forwardedWonMessage => {
+ wonMessage
+ .getContainedForwardedWonMessages()
+ .map(forwardedWonMessage => {
console.debug(
"-- forwardedMessage<",
forwardedWonMessage.getMessageUri(),
@@ -971,6 +974,8 @@ won.wonMessageFromJsonLd = async function(wonMessageAsJsonLD) {
}
return wonMessage;
+ });
+ });
};
/**
