From 829523cfa5177a1810d9373f9a25bf3b18138d1e Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 11 Mar 2021 10:55:09 +0100 Subject: [PATCH] Reduce bundle size using a const enum --- .../users/user-notifications.component.html | 32 +++++++++---------- .../users/user-notifications.component.ts | 3 -- .../custom-validators/user-notifications.ts | 5 ++- .../models/users/user-notification.model.ts | 2 +- 4 files changed, 19 insertions(+), 23 deletions(-) diff --git a/client/src/app/shared/shared-main/users/user-notifications.component.html b/client/src/app/shared/shared-main/users/user-notifications.component.html index 265af8d55..5e0e2f8e8 100644 --- a/client/src/app/shared/shared-main/users/user-notifications.component.html +++ b/client/src/app/shared/shared-main/users/user-notifications.component.html @@ -4,7 +4,7 @@
- + @@ -26,7 +26,7 @@ - +
@@ -34,7 +34,7 @@
- +
@@ -42,7 +42,7 @@
- +
@@ -63,7 +63,7 @@
- +
@@ -73,7 +73,7 @@
- +
@@ -81,7 +81,7 @@
- +
@@ -89,7 +89,7 @@
- + @@ -109,7 +109,7 @@ - +
@@ -117,7 +117,7 @@
- +
@@ -125,7 +125,7 @@
- +
@@ -133,7 +133,7 @@
- +
@@ -141,7 +141,7 @@
- +
@@ -154,7 +154,7 @@
- + @@ -174,7 +174,7 @@ - +
@@ -183,7 +183,7 @@
- +
diff --git a/client/src/app/shared/shared-main/users/user-notifications.component.ts b/client/src/app/shared/shared-main/users/user-notifications.component.ts index 387c49d94..2f6ed061a 100644 --- a/client/src/app/shared/shared-main/users/user-notifications.component.ts +++ b/client/src/app/shared/shared-main/users/user-notifications.component.ts @@ -21,9 +21,6 @@ export class UserNotificationsComponent implements OnInit { notifications: UserNotification[] = [] sortField = 'createdAt' - // So we can access it in the template - UserNotificationType = UserNotificationType - componentPagination: ComponentPagination onDataSubject = new Subject() diff --git a/server/helpers/custom-validators/user-notifications.ts b/server/helpers/custom-validators/user-notifications.ts index 8a33b895b..252c107db 100644 --- a/server/helpers/custom-validators/user-notifications.ts +++ b/server/helpers/custom-validators/user-notifications.ts @@ -1,10 +1,9 @@ -import { exists } from './misc' import validator from 'validator' -import { UserNotificationType } from '../../../shared/models/users' import { UserNotificationSettingValue } from '../../../shared/models/users/user-notification-setting.model' +import { exists } from './misc' function isUserNotificationTypeValid (value: any) { - return exists(value) && validator.isInt('' + value) && UserNotificationType[value] !== undefined + return exists(value) && validator.isInt('' + value) } function isUserNotificationSettingValid (value: any) { diff --git a/shared/models/users/user-notification.model.ts b/shared/models/users/user-notification.model.ts index e2f2234e4..b04619685 100644 --- a/shared/models/users/user-notification.model.ts +++ b/shared/models/users/user-notification.model.ts @@ -1,7 +1,7 @@ import { FollowState } from '../actors' import { AbuseState } from '../moderation' -export enum UserNotificationType { +export const enum UserNotificationType { NEW_VIDEO_FROM_SUBSCRIPTION = 1, NEW_COMMENT_ON_MY_VIDEO = 2, NEW_ABUSE_FOR_MODERATORS = 3,