Fix empty successful response handling for actions

This commit is contained in:
Mo Bitar
2019-06-04 13:09:04 -05:00
parent 44c0a336c2
commit 02fe9dd6b0
4 changed files with 17 additions and 15 deletions

View File

@@ -31,11 +31,13 @@ class ActionsMenu {
} }
return; return;
} }
action.running = true; action.running = true;
actionsManager.executeAction(action, extension, $scope.item, function(response){ actionsManager.executeAction(action, extension, $scope.item, (response, error) => {
if(!response) { if(error) {
return; return;
} }
action.running = false; action.running = false;
$scope.handleActionResponse(action, response); $scope.handleActionResponse(action, response);

View File

@@ -54,10 +54,10 @@ class ActionsManager {
async executeAction(action, extension, item, callback) { async executeAction(action, extension, item, callback) {
var customCallback = (response) => { var customCallback = (response, error) => {
action.running = false; action.running = false;
this.$timeout(() => { this.$timeout(() => {
callback(response); callback(response, error);
}) })
} }
@@ -127,11 +127,10 @@ class ActionsManager {
action.error = false; action.error = false;
handleResponseDecryption(response, await this.authManager.keys(), true); handleResponseDecryption(response, await this.authManager.keys(), true);
}, (response) => { }, (response) => {
if(response && response.error) { let error = (response && response.error) || {message: "An issue occurred while processing this action. Please try again."}
alert("An issue occurred while processing this action. Please try again."); alert(error.message);
}
action.error = true; action.error = true;
customCallback(null); customCallback(null, error);
}) })
} }
break; break;
@@ -142,9 +141,10 @@ class ActionsManager {
action.error = false; action.error = false;
handleResponseDecryption(response, await this.authManager.keys(), false); handleResponseDecryption(response, await this.authManager.keys(), false);
}, (response) => { }, (response) => {
alert("An issue occurred while processing this action. Please try again."); let error = (response && response.error) || {message: "An issue occurred while processing this action. Please try again."}
alert(error.message);
action.error = true; action.error = true;
customCallback(null); customCallback(null, error);
}) })
break; break;

8
package-lock.json generated
View File

@@ -1,6 +1,6 @@
{ {
"name": "standard-notes-web", "name": "standard-notes-web",
"version": "3.0.10-beta1", "version": "3.0.10-beta2",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
@@ -5724,9 +5724,9 @@
} }
}, },
"snjs": { "snjs": {
"version": "0.2.5", "version": "0.2.6",
"resolved": "https://registry.npmjs.org/snjs/-/snjs-0.2.5.tgz", "resolved": "https://registry.npmjs.org/snjs/-/snjs-0.2.6.tgz",
"integrity": "sha512-HFjUD9tvVp5VN6ACmKxTlvpvhBTrLj5t8TSR6tPMOHtCU/ozpmuRgD0RFYfOhUYE5bY1woXC/YFR/Nl77oib3Q==", "integrity": "sha512-nBWwzNcOKtCj6Z0f0buD/vswd3agU+sI2KHWQuUn1tuhNoGdzh20DgjcmxEEmW7QiiEkvZHDL/TC8N47tx66SQ==",
"dev": true "dev": true
}, },
"source-map": { "source-map": {

View File

@@ -39,7 +39,7 @@
"mocha": "^5.2.0", "mocha": "^5.2.0",
"serve-static": "^1.13.2", "serve-static": "^1.13.2",
"sn-stylekit": "2.0.15", "sn-stylekit": "2.0.15",
"snjs": "0.2.5", "snjs": "0.2.6",
"standard-file-js": "0.3.63" "standard-file-js": "0.3.63"
} }
} }