Action manager handle error callback

This commit is contained in:
Mo Bitar
2020-02-03 12:29:34 -06:00
parent 76d1789a8e
commit f5924e75fd
3 changed files with 26 additions and 8 deletions

View File

@@ -50,13 +50,18 @@ export class ActionsManager {
item_uuid: item.uuid item_uuid: item.uuid
}; };
const emptyFunc = () => { }; const emptyFunc = () => { };
return this.httpManager.getAbsolute(extension.url, params, emptyFunc).then((response) => { return this.httpManager.getAbsolute(
extension.url,
params,
emptyFunc,
emptyFunc
).then((response) => {
this.updateExtensionFromRemoteResponse(extension, response); this.updateExtensionFromRemoteResponse(extension, response);
return extension; return extension;
}).catch((response) => { }).catch((response) => {
console.error("Error loading extension", response); console.error("Error loading extension", response);
return null; return null;
}) });
} }
updateExtensionFromRemoteResponse(extension, response) { updateExtensionFromRemoteResponse(extension, response) {
@@ -160,9 +165,15 @@ export class ActionsManager {
const itemParams = await this.outgoingParamsForItem(item, extension, decrypted); const itemParams = await this.outgoingParamsForItem(item, extension, decrypted);
const params = { const params = {
items: [itemParams] items: [itemParams]
} };
/* Needed until SNJS detects null function */
const emptyFunc = () => { }; const emptyFunc = () => { };
return this.httpManager.postAbsolute(action.url, params, emptyFunc).then((response) => { return this.httpManager.postAbsolute(
action.url,
params,
emptyFunc,
emptyFunc
).then((response) => {
action.error = false; action.error = false;
return {response: response}; return {response: response};
}).catch((response) => { }).catch((response) => {
@@ -184,9 +195,10 @@ export class ActionsManager {
} }
async handleGetAction(action) { async handleGetAction(action) {
/* Needed until SNJS detects null function */
const emptyFunc = () => {}; const emptyFunc = () => {};
const onConfirm = async () => { const onConfirm = async () => {
return this.httpManager.getAbsolute(action.url, {}, emptyFunc) return this.httpManager.getAbsolute(action.url, {}, emptyFunc, emptyFunc)
.then(async (response) => { .then(async (response) => {
action.error = false; action.error = false;
await this.decryptResponse(response, await this.authManager.keys()); await this.decryptResponse(response, await this.authManager.keys());
@@ -221,8 +233,14 @@ export class ActionsManager {
} }
async handleRenderAction(action) { async handleRenderAction(action) {
/* Needed until SNJS detects null function */
const emptyFunc = () => {}; const emptyFunc = () => {};
return this.httpManager.getAbsolute(action.url, {}, emptyFunc).then(async (response) => { return this.httpManager.getAbsolute(
action.url,
{},
emptyFunc,
emptyFunc
).then(async (response) => {
action.error = false; action.error = false;
const result = await this.decryptResponse(response, await this.authManager.keys()); const result = await this.decryptResponse(response, await this.authManager.keys());
const item = this.modelManager.createItem(result.item); const item = this.modelManager.createItem(result.item);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long