Esempio n. 1
0
        public virtual async Task Clear()
        {
            var oldNotifications      = _allRemoteNotifications.Union(_allLocalNotifications);
            var oldToastNotifications = _toastNotifications.Union(_localToastNotifications);

            _allRemoteNotifications  = new List <Notification>();
            _toastNotifications      = new List <Notification>();
            _allLocalNotifications   = new List <Notification>();
            _localToastNotifications = new List <Notification>();

            NotificationsRemoved?.Invoke(this, new NotificationsEventArgs(oldNotifications));
            ToastNotificationsRemoved?.Invoke(this, new NotificationsEventArgs(oldToastNotifications));
        }
Esempio n. 2
0
        public virtual async Task DismissNotification(Notification notification)
        {
            bool toastRemoved        = false;
            bool notificationRemoved = false;

            lock (_lock)
            {
                _surpressedNotifications.Add(notification.Id);

                toastRemoved        = _toastNotifications.Remove(notification) || _localToastNotifications.Remove(notification);
                notificationRemoved = _allRemoteNotifications.Remove(notification) || _allLocalNotifications.Remove(notification);
            }

            if (toastRemoved)
            {
                ToastNotificationsRemoved?.Invoke(this, new NotificationsEventArgs(notification));
            }

            if (notificationRemoved)
            {
                NotificationsRemoved?.Invoke(this, new NotificationsEventArgs(notification));
            }
        }