mirror of
https://github.com/nextcloud/server.git
synced 2026-06-11 01:30:50 -04:00
enh(updatenotification): Try to make legacy-notification smart(er)
Fixes #43645 Signed-off-by: Josh <josh.t.richards@gmail.com>
This commit is contained in:
parent
c70a634a0e
commit
e2d3548bfb
1 changed files with 16 additions and 3 deletions
|
|
@ -11,11 +11,24 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* This only gets loaded if an update is available and the notifications app is not enabled for the user.
|
||||
* This only gets loaded if an update is available, but the notifications app has been disabled (but updatechecker isn't disabled).
|
||||
* The goal here is to make sure admins still get an indication there is an update available even if push notifications are disabled.
|
||||
*
|
||||
* Since this is a fallback method that only gets used when the notifications app is disabled, we use toasts to notify, but there's no
|
||||
* intelligence. To avoid constant nagging upon every page reload, we only generate the toasts one day a week on the half hour. This tries to strike
|
||||
* a balance for an admin that disables push notifications. The idea is they still get a periodic reminder of an update being available,
|
||||
* without constant nagging every day upon every page reload. This hopefully reduces likelihood of needing to disable update
|
||||
* checks outright (e.g. by setting `updatechecker => false` in their `config.php` or disabling this app outright too).
|
||||
*
|
||||
*/
|
||||
window.addEventListener('DOMContentLoaded', function(){
|
||||
var text = t('core', '{version} is available. Get more information on how to update.', {version: oc_updateState.updateVersion}),
|
||||
element = $('<a>').attr('href', oc_updateState.updateLink).attr('target','_blank').text(text);
|
||||
|
||||
OC.Notification.showHtml(element.prop('outerHTML'), { type: 'error' });
|
||||
|
||||
today = new Date();
|
||||
dayOfMonth = today.getDate();
|
||||
minuteOfHour = today.getMinutes();
|
||||
if (dayOfMonth % 7 === 0 && minuteOfHour % 30 === 0) { // only toast once a week on the half hour
|
||||
OC.Notification.showHtml(element.prop('outerHTML'), { type: 'error' });
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue