swiftbar / SwiftBar

Powerful macOS menu bar customization tool
https://swiftbar.app
MIT License
2.93k stars 92 forks source link

Icon on click is missing when refreshOnOpen is set to true #272

Closed matopeto closed 2 years ago

matopeto commented 2 years ago

Hi,

i have a problem when i set refreshOnOpen to true

if it is true i have those issues:

  1. icon is disappear when i click on the plugin
  2. plugin seems not updating on click correctly, and also not updating automaticly, sometimes i need to refresh manualy with action on the plugin but not always works

If i remove refreshOnOpen it works correctly

I am using swiftbar current 1.4.2

plugin that not works: https://github.com/matopeto/xcode-build-times/blob/0b02ba10c3d5a4f9fec99ab19e95acc514fb5cda/sources/xcodeBuildTimes.1m.php

(If you will debug the swiftbar with the plugin please update first file with your full path to the PHP executable #!/usr/bin/env php may not work)

melonamin commented 2 years ago

Hey!

icon is disappear when i click on the plugin

This is a bug. On click SwiftBar replaces the image with a hourglass SF Symbol, the idea being to indicate progress for potentially long updating plugins. Looks like the image is not updated back after plugin finished loading. This is maybe my fault or maybe API limitation, I need to test this a bit.

plugin seems not updating on click correctly,

I've re-tested on simple plugins - works as expected. I can't get yours plugin to work properly, but "Build in progress" is updated on each open, so looks like it works(?)

CleanShot 2022-01-28 at 08 05 04@2x

and also not updating automaticly, sometimes i need to refresh manualy with action on the plugin but not always works

SwiftBar implicitly disables auto-refresh for plugins with refreshOnOpen enabled. Why would you want auto-refresh enabled?

matopeto commented 2 years ago

Thanks for quick reply!

I've re-tested on simple plugins - works as expected. I can't get yours plugin to work properly, but "Build in progress" is updated on each open, so looks like it works(?)

It look like works, plugin itself is updating, but not seems correctly. If i am clicking on it every few seconds, it seems to show wrong values, like 30s and then 1m25s. (betwean clicks was not 1 minute delay) I think my plugin is correct and generates correct actual values. But swiftbar shows some old values?

SwiftBar implicitly disables auto-refresh for plugins with refreshOnOpen enabled. Why would you want auto-refresh enabled?

i want to see autoupdated (every minute) build time, to known acutal build time, but when i click on it I want to see actual values (eg. actual build in progress)

Is there any other option to get autoupdate works and also have refresh on click?

melonamin commented 2 years ago

But swiftbar shows some old values?

You're actually correct, I did more testing and it looks like I have a race condition.

i want to see autoupdated (every minute) build time, to known acutal build time, but when i click on it I want to see actual values (eg. actual build in progress)

Got it, makes sense. Let me think about it, maybe I should remove this behavior all together.

melonamin commented 2 years ago

@matopeto can you give a try to this build? SwiftBar.app.zip

matopeto commented 2 years ago

Hi thank you for quick response. I am trying the build with refreshOnOpen true

  1. ✅ icon disappears when i click on the plugin

    • 💡 instead of i see "⏳ ..." for a while. This is very anoying, becaus "loading" state has smaller width as loaded and that keeps all others status bar icons "jumping" left and right. Is there any possibility to disable this behaviour?
    • 💡 Mayby bug/Maybe feature - Highlighted icon have black color and higlighted text have white color. (non highlighted are both black) - but this behaviour is same when refreshOnOpen is false
    1. ✅ when i clicking on the plugin every few seconds, it keeps updating correctly, no old or wrong values ar showed.

      • 💡 But only after first manual "refresh" Use case is: I start the build, i click on the plugin and no "Build in progress row" is showed. Until i manualy click on "refresh" row on my plugin - Refresh| refresh=true and from that time every click on the plugin seems work. Till them seems not refreshing. - but i cannot reproduce this behaviour every time
    2. ⚠️ sometimes when i click on the plugin, it doesn't open and only shows "⏳ ...", after another click it opens and loading state disappear

    3. ⚠️ automatic refresh still don't work when refreshOnOpen is enabled

melonamin commented 2 years ago

Awesome feedback! Please try the new build, it should address all your comments. SwiftBar.app.zip

matopeto commented 2 years ago

@melonamin Great work!!! Thank you! :)

All functional bugs was resolved

Only icon has still other color as text when plugin is open (and maybe the white text is the issue not the black image)

OS: Monterey, dark mode off:

obrazek

When i click on it:

obrazek

With dark mode seems to be OK:

obrazek

When i click on it:

obrazek
melonamin commented 2 years ago

New build

matopeto commented 2 years ago

All OK, thank you :) I am closing the issue