Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Extension settings changed programatically don't show in UI #735

Closed
sebastian-correa opened this issue May 4, 2021 · 0 comments
Closed

Comments

@sebastian-correa
Copy link

Problem

I am trying to implement a reset to default "button" as a select preference. The entry in manifest.json looks like this:

{
      "id": "reset_to_default",
      "type": "select",
      "name": "Reset preferences to default",
      "default_value": "-",
      "options": [
        {
          "value": "-",
          "text": "-"
        },
        {
          "value": "Reset",
          "text": "Reset"
        }
      ]
}

And the PreferencesUpdateListener looks like this:

DEFAULT_PREFERENCES = {"kw": "rae", "max_suggested_items": 10, "max_shown_definitions": 10, "reset_to_default": "-"}
class PreferencesUpdateListener(EventListener):
    def on_event(self, event, extension):
        if event.id == "reset_to_default" and event.new_value == 'Reset':
            for id_, val in DEFAULT_PREFERENCES.items():
                extension.preferences[id_] = val

When I toggle the Reset button to reset and save, the extension's behaviour changes but the UI doesn't reflect that.

Source can be found here.

Steps to reproduce

  1. Define PreferencesUpdateListener with an on_event method that updates a preference with a predefined value.
  2. Before changing values in the UI, test extension to verify it complies with the behaviour reflected in the UI.
  3. Trigger the on_event method (in my case, by toggling a button in the preferences menu).
  4. Verify the extension now behaves as expected, but that the UI shows the old values.

See attached video for illustration.

Current behavior

PreferencesUpdateListener resets the extension.preferences property to its default value and the behaviour changes accordingly. That is, when I use the extension, the new set values are in effect.

However, the extensions settings UI shows the old values.

Expected behavior

When I change the extension.preferences property in a PreferencesUpdateListener, both the behaviour and the values in the settings UI should reflect these new values.

Environment

Ulauncher version: 5.11.0
Linux distro: Pop_OS! 20.10
Desktop environment: Gnome 3.38.3

Logs

Not sure whether they add much information, but here they are. They correspond to the process shown in the video.

Closing remarks

This might not be a bug. I suspect I have to tell the extension to update the UI once the values are set in the code. I did not find a way to do this, and this template suits the issue the best. Feel free to change the tags.

Thanks!

@Ulauncher Ulauncher locked and limited conversation to collaborators Dec 4, 2021
@friday friday converted this issue into discussion #897 Dec 4, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant