Repository navigation
Conversation
| ]); | ||
| } | ||
|
|
||
| private function getNotificationCountInterval(): int |
There was a problem hiding this comment.
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)?
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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?
a5a16c0 to
0fabb9e
Compare
| 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; |
There was a problem hiding this comment.
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?).
There was a problem hiding this comment.
Done, translated on rendering.
| // 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); |
There was a problem hiding this comment.
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.
| return $formBuilder->create( | ||
| 'value', | ||
| ChoiceType::class, | ||
| [ | ||
| 'multiple' => false, | ||
| 'required' => true, | ||
| 'label' => $this->getDescription(), | ||
| 'choices' => $choices, | ||
| ] | ||
| ); |
There was a problem hiding this comment.
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.
0fabb9e to
98e6a89
Compare
98e6a89 to
5f89cea
Compare
5f89cea to
c36008b
Compare
|



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.
notification_count.interval(30000 ms), so nothing changes for users who don't pick a value. It is now also set for thedefaultscope, so user settings work outsideadmin_grouptoo.Screenshots:
User settings
Edit
For QA:
/notifications/countis requested about every 60 s (before: every 30 s).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.intervalSiteAccess setting now sets the default of this per-user setting, which overrides it.