Skip to content

Dispatcher: only notify once per profile#12866

Closed
thialfi17 wants to merge 1 commit into
koreader:masterfrom
thialfi17:notifications
Closed

Dispatcher: only notify once per profile#12866
thialfi17 wants to merge 1 commit into
koreader:masterfrom
thialfi17:notifications

Conversation

@thialfi17

@thialfi17 thialfi17 commented Dec 7, 2024

Copy link
Copy Markdown
Contributor

When notifications are enabled for a profile, a notification is currently triggered for each action that is enabled. Instead, only send one notification by moving outside of the for loop.


This change is Reviewable

@Frenzie Frenzie added this to the 2025.01 milestone Dec 7, 2024
Comment thread frontend/dispatcher.lua Outdated
Comment thread frontend/dispatcher.lua
@thialfi17

Copy link
Copy Markdown
Contributor Author

I've noticed there is a Notification:resetNotifySource() call on line 1202 that is inside the for loop which is probably related. Does anything need changing there to guarantee it gets called (if needed) or is the for-loop always guaranteed to have items to iterate?

@NiLuJe

NiLuJe commented Dec 7, 2024

Copy link
Copy Markdown
Member

've noticed there is a Notification:resetNotifySource() call on line 1202 that is inside the for loop which is probably related. Does anything need changing there to guarantee it gets called (if needed) or is the for-loop always guaranteed to have items to iterate?

Good point.

Since there's no other notify call, you can probably just move it at the end of your new branch outside the loop (i.e., setSource => Notify => ResetSource).

Or, well, this can be simplified to a single notify call with the source being passed to the Notify call itself directly, if there are no longer any other notify calls.

@NiLuJe

NiLuJe commented Dec 7, 2024

Copy link
Copy Markdown
Member

By which I mean, if there's only a single notify call involved, just pass the proper source to it directly.

The whole bracketing thing is only necessary when there are multiple notify calls involved.

function Notification:notify(arg, source, refresh_after)

@NiLuJe

NiLuJe commented Dec 7, 2024

Copy link
Copy Markdown
Member

The whole bracketing thing is only necessary when there are multiple notify calls involved.

Which, actually, there might be... inside whatever the dispatcher actions are going to be running.

So, TL;DR: ignore most of my rambling, but, still, good point, I'd reset the notif source outside the loop, but after it.

@mergen3107

Copy link
Copy Markdown
Contributor

The whole bracketing thing is only necessary when there are multiple notify calls involved.

For example, when a profile (manual or auto triggered) has multiple actions?

@hius07

hius07 commented Jan 18, 2025

Copy link
Copy Markdown
Member

Closed in favor of #13078. Thanks.

@hius07 hius07 closed this Jan 18, 2025
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.

5 participants