Premium Notifications add-on, a few questions

Many of the APIs in the premium Notifications add-on are marked “experimental” and “subject to change or removal.” How accurate is this? It’s a premium add-on…

How often does the icon that gets added via the recommended

<window xmlns="http://jmix.io/schema/ui/window"
        xmlns:ntf="http://jmix.io/schema/notifications/ui"> 
    <layout>
        <cssLayout id="horizontalWrap"
                   stylename="jmix-drawer-layout">
            <drawer id="drawer" expandOnHover="true">
                <!-- ... -->
                <ntf:notificationsIndicator id="ntfIndicator"/> 

… get updated? I’m testing it, and it doesn’t seem to update at all. Is there a way to change or extend this?

Looking at the problem further, I see in NotificationsIndicatorImpl.java there is a reloadCounter() method that gets called by an event listener…

    @EventListener(VaadinSessionNotificationEvent.class)
    public void handlePushEvent(VaadinSessionNotificationEvent event) {
        if (event.isBroadcast()) {
            reloadCounter();
        } else {
            if (currentAuthentication.isSet()) {
                UserDetails user = currentAuthentication.getUser();
                String username = user.getUsername();
                if (username.equals(event.getUsername())) {
                    reloadCounter();
                }
            }
        }
    }

VaadinSessionNotificationEvent is the event published by the in-app notification classes, but this reloadCounter() doesn’t seem to ever happen, or happens on such a delay that I never see it happen in testing.

I have 2 browsers open, one logged in as admin creating notifications for the user logged in on the other browser. The other user’s indicator never updates.

Is there a way to fix this, or can I extend this in some way to make that happen? Or am I missing a configuration parameter somewhere? (Doesn’t seem so though.)

Seems one can “force” an update on an interval by adding a timer into the MainScreen, and doing like this:

    @Subscribe("updateNotiCounterTimer")
    public void onUpdateNotiCounterTimerTimerAction(Timer.TimerActionEvent event) {
        NotificationsIndicator n = (NotificationsIndicator) getWindow().getComponent("ntfIndicator");
        if (n != null) n.reloadCounter();
    }

But I definitely wonder why it is not updating “as needed” when the Vaadin event is published, like the source code would suggest. Bug, or…?

1 Like

Ideas here? :slight_smile:

Hi,
It’s seems to be a bug. I’ve created an issue. We’ll try to fix it in the upcoming 1.3.3 release. Your solution with a timer is good and you may use it for now as a workaround.

1 Like

Excellent, thank you. :slight_smile: