diff --git a/api/src/core/types/states/notification.ts b/api/src/core/types/states/notification.ts index f3fee7cf0..b773ec31b 100644 --- a/api/src/core/types/states/notification.ts +++ b/api/src/core/types/states/notification.ts @@ -1,8 +1,8 @@ export interface NotificationIni { - timestamp: string; - event: string; - subject: string; - description: string; - importance: 'normal' | 'alert' | 'warning'; - link?: string; -} \ No newline at end of file + timestamp: string; + event: string; + subject: string; + description: string; + importance: 'normal' | 'alert' | 'warning'; + link?: string; +} diff --git a/api/src/graphql/generated/api/types.ts b/api/src/graphql/generated/api/types.ts index aeeabe061..89bf765c0 100644 --- a/api/src/graphql/generated/api/types.ts +++ b/api/src/graphql/generated/api/types.ts @@ -793,7 +793,7 @@ export type Notification = Node & { importance: Importance; link?: Maybe; subject: Scalars['String']['output']; - /** ISO Timestamp for when the notification occurred */ + /** ISO Timestamp for when the notification occurred */ timestamp?: Maybe; title: Scalars['String']['output']; type: NotificationType; diff --git a/api/src/graphql/schema/types/notifications/notifications.graphql b/api/src/graphql/schema/types/notifications/notifications.graphql index eb1459f70..14e844496 100644 --- a/api/src/graphql/schema/types/notifications/notifications.graphql +++ b/api/src/graphql/schema/types/notifications/notifications.graphql @@ -46,7 +46,9 @@ type Notification implements Node { importance: Importance! link: String type: NotificationType! - """ ISO Timestamp for when the notification occurred """ + """ + ISO Timestamp for when the notification occurred + """ timestamp: String } @@ -68,4 +70,4 @@ type NotificationCounts { warning: Int! alert: Int! total: Int! -} \ No newline at end of file +} diff --git a/api/src/unraid-api/graph/resolvers/notifications/notifications.service.ts b/api/src/unraid-api/graph/resolvers/notifications/notifications.service.ts index 51a792b6b..398257c1e 100644 --- a/api/src/unraid-api/graph/resolvers/notifications/notifications.service.ts +++ b/api/src/unraid-api/graph/resolvers/notifications/notifications.service.ts @@ -45,6 +45,24 @@ export class NotificationsService { NotificationsService.watcher = this.getNotificationsWatcher(); } + /** + * Returns the paths to the notification directories. + * + * @returns an object with the: + * - base path + * - path to the unread notifications + * - path to the archived notifications + */ + private paths(): Record<'basePath' | NotificationType, string> { + const basePath = getters.dynamix().notify!.path; + const makePath = (type: NotificationType) => join(basePath, type.toLowerCase()); + return { + basePath, + [NotificationType.UNREAD]: makePath(NotificationType.UNREAD), + [NotificationType.ARCHIVE]: makePath(NotificationType.ARCHIVE), + }; + } + /**------------------------------------------------------------------------ * Subscription Events * @@ -92,21 +110,6 @@ export class NotificationsService { }); } - private async addToOverview(notification: Notification) { - const { type, importance } = notification; - - NotificationsService.overview[type.toLowerCase()][importance.toLowerCase()] += 1; - NotificationsService.overview[type.toLowerCase()]['total'] += 1; - - pubsub.publish(PUBSUB_CHANNEL.NOTIFICATION_ADDED, { - notificationAdded: notification, - }); - - pubsub.publish(PUBSUB_CHANNEL.NOTIFICATION_OVERVIEW, { - notificationsOverview: NotificationsService.overview, - }); - } - private async removeFromOverview(notification: Notification) { const { type, id, importance } = notification; this.logger.debug(`Removing ${type} Notification: ${id}`); @@ -415,22 +418,4 @@ export class NotificationsService { } return null; } - - /** - * Returns the paths to the notification directories. - * - * @returns an object with the: - * - base path, - * - path to the unread notifications, - * - path to the archived notifications - */ - private paths(): Record<'basePath' | NotificationType, string> { - const basePath = getters.dynamix().notify!.path; - const makePath = (type: NotificationType) => join(basePath, type.toLowerCase()); - return { - basePath, - [NotificationType.UNREAD]: makePath(NotificationType.UNREAD), - [NotificationType.ARCHIVE]: makePath(NotificationType.ARCHIVE), - }; - } } diff --git a/api/src/utils.ts b/api/src/utils.ts index 5dd5c4d8a..8b7e38acd 100644 --- a/api/src/utils.ts +++ b/api/src/utils.ts @@ -1,5 +1,5 @@ export function notNull(value: T): value is NonNullable { - return value !== null; + return value !== null; } /** @@ -9,7 +9,7 @@ export function notNull(value: T): value is NonNullable { * @returns true if the result is fulfilled, false otherwise. */ export function isFulfilled(result: PromiseSettledResult): result is PromiseFulfilledResult { - return result.status === 'fulfilled'; + return result.status === 'fulfilled'; } /** @@ -19,5 +19,5 @@ export function isFulfilled(result: PromiseSettledResult): result is Promi * @returns true if the result is rejected, false otherwise. */ export function isRejected(result: PromiseSettledResult): result is PromiseRejectedResult { - return result.status === 'rejected'; -} \ No newline at end of file + return result.status === 'rejected'; +}