swiftDialog icon indicating copy to clipboard operation
swiftDialog copied to clipboard

Updating image with Command file fails

Open mike-wolf23 opened this issue 1 year ago • 3 comments

Describe the bug When updating --image with the command file "image: /path/to/image" it does not update the image, instead it creates an image array for a slide show.

also, updating "image: /path/to/image" with the --message "$message" flag causes it to not update any image.

To Reproduce Steps to reproduce the behavior:

  1. set --image "/path/to/image" and then update via command file "image: /path/to/newimage"

Expected behavior Expected the image to be replaced with the new image and not create a slideshow. Expected image to update with a message as well. Saw FR#194 and says --image and --message can be used together.

Desktop (please complete the following information):

  • macOS version : 14.2.1
  • swiftDialog version : 2.3.3.4734

mike-wolf23 avatar Jan 12 '24 14:01 mike-wolf23

Hey @mike-wolf23, I agree a single command to do this would be ideal. However, for now you can work around this limitation by first sending an image: clear command to your command file and then sending an image: pathtoimage command immediately after.

There is a small flash as the image gets replaced but it does work.

drtaru avatar Jan 23 '24 16:01 drtaru

That's a pretty easy workaround to use, so thank you!

I'll verify the experience but this may be what is needed to get us by for now.

mike-wolf23 avatar Jan 23 '24 16:01 mike-wolf23

Yeah, so having a look at the report and it's behaving as intended.....or rather, behaving as it was programmed to behave. The documentation on the wiki could be better.

That said, here's how it's written to work (assume every command is completed with >> /var/tmp/dialog.log:

  • sending image: /path/to/image.png will append to the current image array and display the image array, hiding the message text.
    • If this is the first image then this obviously changes the array from size 0 to 1
    • an array of size 1 is shown without an image carousel.
  • sending message: Some Text Here will hide image content and show the message content
    • the existing image array is still held in memory, it's just hidden from view
  • use image: show or image: hide to display or remove the image array from view
  • use image: clear to clear the array.

As to why it is this way? --image as used on the command line or in json are what I called in the code a multi option. That is you can specify --image as many times as you want and it will build up an array of content. This means that when using the command file it's performs an additive action, not a replace action.

Given that this is how it's written, there is scope to augment how this works. So if you want to replace the image with a new one then there's a few ways we could do it and maintain how it works currently (for people that are using it as it works and we don't break their workflow)

  • image: update: /path/to/image.png
  • image: replace: /path/to/image.png
  • image: clear: /path/to/image.png

Or some other variation (open to suggestions)

bartreardon avatar Feb 27 '24 03:02 bartreardon