Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CallBackMessage Template #7

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions Flow.Launcher.Plugin.PythonTemplate/plugin/templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
}

ACTION_TEMPLATE = {
'JsonRPCAction': {
'method': '',
'parameters': [],
}
'method': '',
'parameters': [],
}
8 changes: 7 additions & 1 deletion Flow.Launcher.Plugin.PythonTemplate/plugin/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@

class Main(FlowLauncher):
messages_queue = []

def callBackMethodSample(self, **args):
action = copy.deepcopy(ACTION_TEMPLATE)
// do what you want to do

return message
Comment on lines +14 to +18
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function seems duplicated to sendNormalMess and sendActionMess.

And what the message variable is used to do?


def sendNormalMess(self, title: str, subtitle: str):
message = copy.deepcopy(RESULT_TEMPLATE)
Expand All @@ -28,7 +34,7 @@ def sendActionMess(self, title: str, subtitle: str, method: str, value: List):
action = copy.deepcopy(ACTION_TEMPLATE)
action['JsonRPCAction']['method'] = method
action['JsonRPCAction']['parameters'] = value
message.update(action)
message['JsonRPCAction'] = action;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this your meaning?

# information
message = copy.deepcopy(RESULT_TEMPLATE)
message['Title'] = title
message['SubTitle'] = subtitle

# action
action = copy.deepcopy(ACTION_TEMPLATE)
action['method'] = method
action['parameters'] = value

message.update(action)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, but I would like to change Action-Template without the wrapper, because Flow's JsonRPCRequestModel is without the wrapper. This aligns with your design that RESULT_TEMPLATE is not {result:{~~~}}.


self.messages_queue.append(message)

Expand Down