|
|
|
@ -1,6 +1,5 @@ |
|
|
|
|
import { createSlice, PayloadAction } from '@reduxjs/toolkit'; |
|
|
|
|
|
|
|
|
|
import { config } from '@grafana/runtime'; |
|
|
|
|
import { AppNotification, AppNotificationSeverity, AppNotificationsState } from 'app/types/'; |
|
|
|
|
|
|
|
|
|
const MAX_STORED_NOTIFICATIONS = 25; |
|
|
|
@ -88,10 +87,6 @@ function isStoredNotification(obj: any): obj is StoredNotification { |
|
|
|
|
// (De)serialization
|
|
|
|
|
|
|
|
|
|
export function deserializeNotifications(): Record<string, StoredNotification> { |
|
|
|
|
if (!config.featureToggles?.persistNotifications) { |
|
|
|
|
return {}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const storedNotifsRaw = window.localStorage.getItem(STORAGE_KEY); |
|
|
|
|
if (!storedNotifsRaw) { |
|
|
|
|
return {}; |
|
|
|
@ -106,10 +101,6 @@ export function deserializeNotifications(): Record<string, StoredNotification> { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function serializeNotifications(notifs: Record<string, StoredNotification>) { |
|
|
|
|
if (!config.featureToggles?.persistNotifications) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const reducedNotifs = Object.values(notifs) |
|
|
|
|
.filter(isAtLeastWarning) |
|
|
|
|
.sort((a, b) => b.timestamp - a.timestamp) |
|
|
|
|