Poll for new notifications every 10sec
This commit is contained in:
@@ -71,6 +71,23 @@ angular.module('Application').controller('MainController', ['$scope', '$route',
|
||||
$('#setupSubscriptionModal').modal('show');
|
||||
};
|
||||
|
||||
function refreshNotifications() {
|
||||
Client.getNotifications(false, 1, 20, function (error, results) {
|
||||
var newNotifications = results.filter(function (a) {
|
||||
return !$scope.notifications.find(function (b) {
|
||||
return a.id === b.id;
|
||||
});
|
||||
});
|
||||
|
||||
newNotifications.forEach(function (n) {
|
||||
$scope.notifications.push(n);
|
||||
Client.notify(n.title, n.message, false, 'info', n.action);
|
||||
});
|
||||
|
||||
$timeout(refreshNotifications, 10000);
|
||||
});
|
||||
}
|
||||
|
||||
function runConfigurationChecks() {
|
||||
if ($scope.config.update && $scope.config.update.box) {
|
||||
Client.notify('Update Available', 'Update now to version ' + $scope.config.update.box.version + '.', true, 'success', '/#/settings');
|
||||
@@ -95,13 +112,7 @@ angular.module('Application').controller('MainController', ['$scope', '$route',
|
||||
Client.notify('Reboot Required', 'To finish security updates, a reboot is necessary.', true /* persistent */, 'warning', '/#/system');
|
||||
});
|
||||
|
||||
Client.getNotifications(false, 1, 100, function (error, results) {
|
||||
$scope.notifications = results;
|
||||
|
||||
results.forEach(function (n) {
|
||||
Client.notify(n.title, n.message, false, 'info', n.action);
|
||||
});
|
||||
});
|
||||
refreshNotifications();
|
||||
}
|
||||
|
||||
$scope.fetchAppstoreProfileAndSubscription = function (callback) {
|
||||
|
||||
Reference in New Issue
Block a user