Jump to content

"mods" object for Text View JSON Format


Recommended Posts

Hi,

 

Summary of Request:

 

Can the Text View JSON Format be extended to allow for a "mods" object like the Script View JSON Format already supports?

 

Use Case:

 

I have a workflow where the modifier text is dynamic based on some preferences driven by the script. For example, I have a user preference in my workflow that determines whether the selected result copies to clipboard by default, or opens in the browser by default (with the Command key triggering whichever behavior is not the default).

 

I accomplish this by setting a variable and then using a Conditional utility object to decide which action to take. But because I can't set a modifier on a connection after the Conditional (only before), I need to determine the modifier text before the conditional runs. So I dynamically set that modifier text using the "mods" object in each result of my Script Filter output.

 

However, since the Text View JSON format does not allow for a "mods" object, I have to add a Conditional object earlier in the pipeline, which requires adding a duplicate Text View object with connections that are the inverse of the other text view (i.e. text view 1 has Command going to the secondary action, and text view 2 has Command going to the primary action).

 

image.thumb.png.ae0e4c254d80bf6230d2ef008aa16e60.png

 

It's all rather complicated to explain, but it's the only solution I was able to devise to work around the lack of a "mods" object for the Text View JSON. Please let me know if you have any further questions on my particular use case, but I think it should already make sense what I am asking for.

Edited by caleb531
Adding image attachment
Link to comment
Share on other sites

You can set the mods in the Script Filter’s JSON, with custom text. You can go further: have mods in your Script Filter set the subtitle text and a variable whose name is consistent for each modifier but the value is specific. Then, from your Script Filter you’ll only have one connection out to a conditional which checks the variable’s value and branches accordingly.


I use this technique in a few workflows, e.g Pin Plus.

Link to comment
Share on other sites

Posted (edited)

@vitor That's a very innovative technique, but unfortunately I don't think it solves the problem (particularly since the workflow you provided does not include a Text View). Even if I expose a variable or subtitle from my Script Filter when a modifier is pressed, my Text View (later down the chain) cannot display it dynamically.

 

I got pretty close with a variable-based approach like the one you described. However, it seems that the Text View footer, as well as modifier subtext for connections attached to a Text View, cannot contain variables. However, modifier subtexts for connections attached to a Script Filter do correctly resolve variables.

 

In other words, the modifier subtext field can resolve variables when attached to a Script Filter, but not when attached to a Text View. If this can be added/fixed, my problem would be solved.

 

To demonstrate this issue, I have created a sample workflow for you to examine and run. You can download it here:

https://fastupload.io/o58i5qIPG8M9ty6/file

 

Here are the steps to explain the bug:

 

  1. Install the workflow linked above
  2. Type the bug keyword into Alfred
  3. Hold down the Command key; you will see the modifier subtext correctly resolving the variable I have set for that result
  4. Action either result by pressing Command+Enter
  5. Observe problem 1: after reaching the Text View and releasing the Command key, notice how the footer text statically defined in the Text View object cannot resolve variables, since {var:primary_action} is showing in the footer, rather than "Primary action for result X (from variable)"
  6. Observe problem 2: Now, if you hold down the Command key while still on the Text View, you will notice the footer does indeed change, but again, the variable in the subtext does not correctly resolve—it's showing a literal {var:secondary_action} in the footer, rather than "Secondary action for result X (from variable)"
Edited by caleb531
Adding more details of issue and how to reproduce with sample workflow
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...