Skip to content

IBX-12711: Allowed users to set how often notifications are checked - #2224

Open
tbialcz wants to merge 1 commit into
6.0from
IBX-12711-notification-check-frequency
Open

tbialcz wants to merge 1 commit into
6.0from
IBX-12711-notification-check-frequency

Conversation

@tbialcz

@tbialcz tbialcz commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor
🎫 Issue IBX-12711

Description:

The back office checks for new notifications every 30 seconds. Users can now change that in User settings → Browsing → Check for new notifications every: 30 seconds, 1, 5, 15 or 30 minutes.

  • The default is still the SiteAccess setting notification_count.interval (30000 ms), so nothing changes for users who don't pick a value. It is now also set for the default scope, so user settings work outside admin_group too.
  • Users may pick a shorter interval than the configured default: it is their own browser session.
  • A configured default or a stored value that isn't one of the presets is offered in the list as well, so saving the Browsing group doesn't replace it.
  • Like the other user settings, saving the Browsing group stores the current interval, so a later change of the configured default no longer applies to that user.

Screenshots:

User settings

User settings

Edit

Edit

For QA:

  1. User settings → Browsing: "Check for new notifications every: 30 seconds".
  2. Edit → pick 1 minute → Save → the list shows "1 minute".
  3. Reload any back-office page: in the browser dev tools, /notifications/count is requested about every 60 s (before: every 30 s).
  4. Change another Browsing setting (e.g. sub-items) and save: the interval stays at 1 minute.
  5. Another user without a saved value still gets 30 seconds.
  6. With ibexa.system.admin_group.notification_count.interval: 45000, a user without a saved value sees "45 seconds" and the list offers it.

Documentation:

User settings page (doc.ibexa.co, "User settings"/"Notifications"): add the new "Check for new notifications every" setting in the Browsing group. The notification_count.interval SiteAccess setting now sets the default of this per-user setting, which overrides it.

@tbialcz
tbialcz requested a review from a team November 17, 2026 06:54
@tbialcz tbialcz added the Doc needed The changes require some documentation label Nov 17, 2026
]);
}

private function getNotificationCountInterval(): int

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getNotificationCountInterval() has no test. It uses the stored value only when it is digits and greater than 0, and otherwise falls back to notification_count.interval. Removing the ctype_digit check, the > 0 check or the fallback would not turn any test red. Could we add a test for it (a stored valid value, '0' or a non-numeric value, and the default)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, moved it to NotificationCountInterval::resolveInterval() and covered it with a test.

</trans-unit>
<trans-unit id="7dc44e03fe0f628635ede226c1cc06bbb3c92f57" resname="settings.notification_count_interval.value.title">
<source>Notification check frequency</source>
<target state="new">Notifications</target>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The target of settings.notification_count_interval.value.title is "Notifications", but the source and the @Desc in NotificationCountInterval::getName() are "Notification check frequency". The other new units have the target equal to the source. Could we make the target match the source?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@tbialcz
tbialcz force-pushed the IBX-12711-notification-check-frequency branch from a5a16c0 to 0fabb9e Compare November 20, 2026 08:49
Comment on lines +126 to +144
if ($interval > 0 && $interval % self::MS_PER_MINUTE === 0) {
return $this->translator->trans(
/** @Desc("{1}%count% minute|]1,Inf]%count% minutes") */
'settings.notification_count_interval.value.minutes',
['%count%' => intdiv($interval, self::MS_PER_MINUTE)],
'ibexa_user_settings'
);
}

if ($interval > 0 && $interval % self::MS_PER_SECOND === 0) {
return $this->translator->trans(
/** @Desc("{1}%count% second|]1,Inf]%count% seconds") */
'settings.notification_count_interval.value.seconds',
['%count%' => intdiv($interval, self::MS_PER_SECOND)],
'ibexa_user_settings'
);
}

return (string)$interval;

@Steveb-p Steveb-p Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Translations for the form are usually done during template rendering (choice_translation_domain). Ensure that translating them does not trigger another translation attempt on the actual display (it happens wayyy too often in our code).

If it does, prefer translating during rendering instead.

Also, ensure that the value sent to the server "makes sense" (in other words, what's the value of the input that is being sent to the form?).

@tbialcz tbialcz Nov 20, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, translated on rendering.

Comment on lines +88 to +94
// The default and the stored value are offered too: a stored value missing from the choices would be
// replaced by the first one whenever the user saves the group.
$intervals = array_filter(
array_unique([...self::PRESETS, (int)$this->getDefaultValue(), $this->getStoredInterval($formBuilder)]),
static fn (int $interval): bool => $interval > 0
);
sort($intervals);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the stored value is not available in the form choices, it should be removed. It has stopped being a valid value.

Static choice list is good, default should be part of it - we don't need to dynamically build it.

It would also remove the whole need for dynamically generated labels.

@tbialcz tbialcz Nov 20, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment on lines +101 to +110
return $formBuilder->create(
'value',
ChoiceType::class,
[
'multiple' => false,
'required' => true,
'label' => $this->getDescription(),
'choices' => $choices,
]
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say constraints in in order here.

https://symfony.com/doc/current/reference/constraints/Choice.html maybe, if not GreaterThan to ensure we're not allowing an extremely low value.

@tbialcz tbialcz Nov 20, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@tbialcz
tbialcz force-pushed the IBX-12711-notification-check-frequency branch from 0fabb9e to 98e6a89 Compare November 20, 2026 11:03
@tbialcz
tbialcz requested a review from Steveb-p November 20, 2026 11:03
@tbialcz
tbialcz force-pushed the IBX-12711-notification-check-frequency branch from 98e6a89 to 5f89cea Compare November 20, 2026 11:08
@katarzynazawada
katarzynazawada force-pushed the IBX-12711-notification-check-frequency branch from 5f89cea to c36008b Compare November 20, 2026 14:01
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Doc needed The changes require some documentation Ready for QA Ready for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants