From cdc0251371f3d0f222e2ec2f76b02876f73499a2 Mon Sep 17 00:00:00 2001 From: george Date: Tue, 31 Aug 2021 15:27:43 +0500 Subject: [PATCH] Show error messages from Miro responses --- .../Contents/Sketch/core/api.js | 9 +++++---- .../Contents/Sketch/core/ui.js | 14 +++++++++----- .../Contents/Sketch/manifest.json | 2 +- appcast.xml | 5 ++++- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/RealtimeBoard.sketchplugin/Contents/Sketch/core/api.js b/RealtimeBoard.sketchplugin/Contents/Sketch/core/api.js index 4ca982d..1c4acf6 100644 --- a/RealtimeBoard.sketchplugin/Contents/Sketch/core/api.js +++ b/RealtimeBoard.sketchplugin/Contents/Sketch/core/api.js @@ -272,9 +272,9 @@ function Api() { var artboards = [page artboards]; if (artboards.length == 0) { - return this.UploadEnum.NO_ARTBOARDS; + return { result: this.UploadEnum.NO_ARTBOARDS }; } else { - return this.UploadEnum.NO_ARTBOARDS_SELECTED; + return { result: this.UploadEnum.NO_ARTBOARDS_SELECTED }; } } @@ -375,12 +375,13 @@ function Api() { if (res != null) { if (res.error != nil) { logErr(res.error) + return { result: this.UploadEnum.UPLOAD_FAILED, error: res.error } } else { for (var i = 0; i < res.widgets.length; i++) { var artboard = exportInfoList[i]; context.command.setValue_forKey_onLayer_forPluginIdentifier(res.widgets[i]["resourceId"], boardId, artboard.artboard, "rtb_sync"); } - return this.UploadEnum.SUCCESS; + return { result: this.UploadEnum.SUCCESS }; } } else { logErr('res == null') @@ -389,7 +390,7 @@ function Api() { logErr('classNameOfOuput == _NSZeroData') } - return this.UploadEnum.UPLOAD_FAILED; + return { result: this.UploadEnum.UPLOAD_FAILED }; } Api.prototype.artboardsToPNG = function(context, exportAll, scale) { diff --git a/RealtimeBoard.sketchplugin/Contents/Sketch/core/ui.js b/RealtimeBoard.sketchplugin/Contents/Sketch/core/ui.js index ea1630b..ab0f906 100644 --- a/RealtimeBoard.sketchplugin/Contents/Sketch/core/ui.js +++ b/RealtimeBoard.sketchplugin/Contents/Sketch/core/ui.js @@ -702,7 +702,7 @@ function UI() { [syncButton setCOSJSTargetFunction:undefined]; COScript.currentCOScript().setShouldKeepAround_(false); - if (uploadResult == api.UploadEnum.SUCCESS) { + if (uploadResult.result == api.UploadEnum.SUCCESS) { api.setLastBoardId(boardId); if (openBoard.state() == 1) { @@ -711,12 +711,16 @@ function UI() { [[NSWorkspace sharedWorkspace] openURL:url]; } - } else if (uploadResult == api.UploadEnum.NO_ARTBOARDS) { + } else if (uploadResult.result == api.UploadEnum.NO_ARTBOARDS) { showAlert("No artboards on the page?", "Please create an artboard or open another file.", context); - } else if (uploadResult == api.UploadEnum.NO_ARTBOARDS_SELECTED) { + } else if (uploadResult.result == api.UploadEnum.NO_ARTBOARDS_SELECTED) { showAlert("No artboards selected?", "Please choose an artboard and retry.", context); - } else if (uploadResult == api.UploadEnum.UPLOAD_FAILED) { - showAlert("An error occurred", "There was an error during syncing. Please retry.", context); + } else if (uploadResult.result == api.UploadEnum.UPLOAD_FAILED) { + if (uploadResult.error && uploadResult.error.message) { + showAlert("An error occurred", uploadResult.error.message, context); + } else { + showAlert("An error occurred", "There was an error during syncing. Please retry.", context); + } } } }]; diff --git a/RealtimeBoard.sketchplugin/Contents/Sketch/manifest.json b/RealtimeBoard.sketchplugin/Contents/Sketch/manifest.json index c370b01..7111b20 100644 --- a/RealtimeBoard.sketchplugin/Contents/Sketch/manifest.json +++ b/RealtimeBoard.sketchplugin/Contents/Sketch/manifest.json @@ -1,7 +1,7 @@ { "name": "Miro", "identifier" : "com.realtimeboard.sketch.plugin", - "version" : "1.6.1", + "version" : "1.6.2", "description" : "Export and sync your artboards with Miro", "authorEmail" : "support@miro.com", "author" : "Miro", diff --git a/appcast.xml b/appcast.xml index 690314f..9910a38 100644 --- a/appcast.xml +++ b/appcast.xml @@ -2,7 +2,10 @@ - + + + +