apdatifier icon indicating copy to clipboard operation
apdatifier copied to clipboard

Duplicate widget + tray instances don’t share state: double update checks, unsynced UI, config divergence

Open Txoka opened this issue 4 months ago • 4 comments

Issue:

  • If you add the panel widget to the desktop as well as the tray icon, each instance:
  • Starts its own update-checking loop (Timer searchTimer → JS.checkUpdates()), so checkupdates, etc. run twice.
  • Maintains a separate in-memory cache/news/config, so read/unread news items and pending-updates drift apart.
  • Shows duplicate notifications. (I didn't fully verify this, but I think I've seen it happen.)
  • They can interfere with each other if they check for updates at the same time and cause an error.

Reproduction:

  • Install Apdatifier (Plasma 6, Arch).
  • Leave the default tray icon alive.
  • Add the widget to the desktop.
  • Mark a news item as read in one instance => the other still shows it unread (until updated).
  • Change a setting in one plasmoid’s config screen => the other keeps the previous value (until updated).

Expected behaviour

  • Only one background job should perform update/news checks.
  • All visible instances (tray, panel, desktop) should reflect the same cache/news/config immediately.
  • Notifications should be emitted only once per event, not per instance.

Attempted fix:

  • A simple lock-file (apdatifier.lock) so only one instance keeps searchTimer running.
  • A FolderListModel directory watcher to reload config/cache/news on change. Unfortunately, I know nothing about plasma / plasmoids so I only managed to break it.

Also, I think the ideal solution would have a separate process (systemd?) run the updates and all the widgets listening and talking to that.

Txoka avatar Aug 05 '25 15:08 Txoka

Unfortunately, I don’t have much time right now, and it won’t change anytime soon. Otherwise, I’d like to rewrite a lot of things, the code is messy, and many parts need to be optimized, and simplified.

https://github.com/user-attachments/assets/75d68b3e-6b98-40c2-9632-fb6e9bc9a128

  • The first widget instance becomes the "primary" one, and only this widget runs the timer to automatically check for updates.
  • If you manually click “Check for updates” on a widget it becomes the "primary".
  • I don’t know how notifications behave with multiple monitors, but since only one widget actually checks for updates, the notifications will come from it. I’m not sure on which monitor they will appear.
  • All configuration files are synchronized immediately, including the main configuration file. Initially, I implemented saving the config to a file because the widget in the system tray is removed (along with its settings) during its upgrade, and then it’s added again without the previous settings. Widgets on the panel don’t have this problem.

exequtic avatar Aug 09 '25 08:08 exequtic

Is that suposed to be the normal behavior of the widget? That doesnt seem to be the case for me:

https://github.com/user-attachments/assets/7429791c-6efa-4b6d-a288-5cbf964c65fc

Txoka avatar Aug 09 '25 13:08 Txoka

I haven’t pushed any changes to GitHub yet. It’s still a rough version and has bugs.

exequtic avatar Aug 09 '25 13:08 exequtic

Oh, okey, ill be waiting for it ;)

Txoka avatar Aug 09 '25 14:08 Txoka