Skip to content

update tray menu before sending MenuDiff event #21

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

Levizor
Copy link
Contributor

@Levizor Levizor commented Feb 23, 2025

fixed #20 for me

@Levizor
Copy link
Contributor Author

Levizor commented Feb 26, 2025

Now also updating StatusNotifierItem on properties update.

@JakeStanger
Copy link
Owner

Thanks for this.

Re-fetching the entire menu isn't supposed to be necessary when fetching a single property, but it does not shock me at all that there are implementations bad enough to make it necessary.

This does effectively duplicate the layout updated case above - if we're re-fetching the layout in both, could you look to see if you could condense them down please?

@Levizor
Copy link
Contributor Author

Levizor commented Feb 28, 2025

Thanks for this.

Re-fetching the entire menu isn't supposed to be necessary when fetching a single property, but it does not shock me at all that there are implementations bad enough to make it necessary.

This does effectively duplicate the layout updated case above - if we're re-fetching the layout in both, could you look to see if you could condense them down please?

I used this as a quick fix to make my project work, cause I didn't bother creating my own implementation of this map.

I agree that it should be rewritten and ideally we should update only the changed properties in TrayMenu and StatusNotifierItem.

I may have some time to try tackling this problem, but I should warn you that I am very new to Rust, so it's better to double-check my code and possibly direct me with finding out solution.

For this specific case I guess I'll need to create a function to apply vector of MenuDiffs to the actual menu and similarly for the status notifier item.

@Levizor Levizor force-pushed the changing-items-state-on-events branch from 1f342b4 to e56dfd6 Compare March 4, 2025 00:34
@Levizor
Copy link
Contributor Author

Levizor commented Mar 4, 2025

Seems to work. Now it doesn't re-fetch entire menu but applies the updates to the existing ones in items map.
Had to adapt to upstream/master which hides map behind the feature flag. I suppose I should hide new methods inside TrayItemMap. Will work on it soon.

@Levizor Levizor force-pushed the changing-items-state-on-events branch from 162a03f to b71553b Compare March 4, 2025 21:23
@Levizor
Copy link
Contributor Author

Levizor commented Mar 4, 2025

Let me know what you think and what changes should be applied.

I also wonder why there is no methods implemented on the actual structures such as TrayMenu or MenuItem to feed updates/diffs for them to change. I think it would be beneficial to have those, in case of disabled "data" feature as well.

Or maybe I missed something and my implementations to apply updates to the structures is redundant or inefficient?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TrayMenu properties in items map aren't updated on MenuDiff event
2 participants