Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

$agent actions break success chaining #65

Open
rolloclarke opened this issue Oct 24, 2019 · 2 comments
Open

$agent actions break success chaining #65

rolloclarke opened this issue Oct 24, 2019 · 2 comments
Assignees
Labels
jasonette-android Jasonette Android related issues

Comments

@rolloclarke
Copy link

Describe the bug
If an action triggers another action which is of type $agent.request and $return.success is returned, the original action's success is never executed.

So the yay success alert of action1 is never executed:

"action1": {
	"type": "trigger",
	"options": {
		"name": "action2"
	},
	"success": {
		"type": "$util.alert",
		"options": {
			"title": "YAY",
			"description": "yay"
		}
	}
},
"action2": {
	"type": "$agent.request",
	"options": {
		"id": "someid",
		"method": "whatever"
	},
	"success": {
		"type": "$return.success"
	}
}

This is true of all agent actions not just $agent.request

The problem is
In JasonAgentAction the caller event object is ignored, and never passed through to the JasonAgentService, and so all the JasonHelper.next(...) calls are made with empty event objects.

@clsource
Copy link
Contributor

thanks for reporting :)

@clsource
Copy link
Contributor

clsource commented Sep 9, 2021

Upon some testing it seems that At least Android needs a little time. Around 100 ms before responding to an action so the system can process it.

Example from $media.permissions

// We need at least 100 ms to call the success with the result
            // If not then it will be omitted since it will too fast 
            // for the system to process.
            new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
                @Override
                public void run() {
                    try {
                        JSONObject ret = new JSONObject();
                        ret.put("files", ContextCompat.checkSelfPermission(context, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED);
                        ret.put("camera", ContextCompat.checkSelfPermission(context, Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED);
                        JasonHelper.next("success", action, ret, event, context);
                    }  catch (Exception e) {
                        Log.d("Warning", e.getStackTrace()[0].getMethodName() + " : " + e.toString());
                    }
                }
            }, 100); // Millisecond 1000 = 1 sec

https://raw.githubusercontent.com/jasonelle/jasonette-android/f1329f999a29e39bba53cdd78066d3ed2ff315e1/app/src/main/java/com/jasonette/seed/Action/JasonMediaAction.java

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
jasonette-android Jasonette Android related issues
Projects
None yet
Development

No branches or pull requests

3 participants