mirror of https://github.com/Chocobozzz/PeerTube
Reduce bundle size using a const enum
parent
5d43dae369
commit
829523cfa5
|
@ -4,7 +4,7 @@
|
||||||
<div *ngFor="let notification of notifications" class="notification" [ngClass]="{ unread: !notification.read }" (click)="markAsRead(notification)">
|
<div *ngFor="let notification of notifications" class="notification" [ngClass]="{ unread: !notification.read }" (click)="markAsRead(notification)">
|
||||||
|
|
||||||
<ng-container [ngSwitch]="notification.type">
|
<ng-container [ngSwitch]="notification.type">
|
||||||
<ng-container *ngSwitchCase="UserNotificationType.NEW_VIDEO_FROM_SUBSCRIPTION">
|
<ng-container *ngSwitchCase="1"> <!-- UserNotificationType.NEW_VIDEO_FROM_SUBSCRIPTION -->
|
||||||
<ng-container *ngIf="notification.video; then hasVideo; else noVideo"></ng-container>
|
<ng-container *ngIf="notification.video; then hasVideo; else noVideo"></ng-container>
|
||||||
|
|
||||||
<ng-template #hasVideo>
|
<ng-template #hasVideo>
|
||||||
|
@ -26,7 +26,7 @@
|
||||||
</ng-template>
|
</ng-template>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<ng-container *ngSwitchCase="UserNotificationType.UNBLACKLIST_ON_MY_VIDEO">
|
<ng-container *ngSwitchCase="5"> <!-- UserNotificationType.UNBLACKLIST_ON_MY_VIDEO -->
|
||||||
<my-global-icon iconName="undo" aria-hidden="true"></my-global-icon>
|
<my-global-icon iconName="undo" aria-hidden="true"></my-global-icon>
|
||||||
|
|
||||||
<div class="message" i18n>
|
<div class="message" i18n>
|
||||||
|
@ -34,7 +34,7 @@
|
||||||
</div>
|
</div>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<ng-container *ngSwitchCase="UserNotificationType.BLACKLIST_ON_MY_VIDEO">
|
<ng-container *ngSwitchCase="4"> <!-- UserNotificationType.BLACKLIST_ON_MY_VIDEO -->
|
||||||
<my-global-icon iconName="no" aria-hidden="true"></my-global-icon>
|
<my-global-icon iconName="no" aria-hidden="true"></my-global-icon>
|
||||||
|
|
||||||
<div class="message" i18n>
|
<div class="message" i18n>
|
||||||
|
@ -42,7 +42,7 @@
|
||||||
</div>
|
</div>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<ng-container *ngSwitchCase="UserNotificationType.NEW_ABUSE_FOR_MODERATORS">
|
<ng-container *ngSwitchCase="3"> <!-- UserNotificationType.NEW_ABUSE_FOR_MODERATORS -->
|
||||||
<my-global-icon iconName="flag" aria-hidden="true"></my-global-icon>
|
<my-global-icon iconName="flag" aria-hidden="true"></my-global-icon>
|
||||||
|
|
||||||
<div class="message" *ngIf="notification.videoUrl" i18n>
|
<div class="message" *ngIf="notification.videoUrl" i18n>
|
||||||
|
@ -63,7 +63,7 @@
|
||||||
</div>
|
</div>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<ng-container *ngSwitchCase="UserNotificationType.ABUSE_STATE_CHANGE">
|
<ng-container *ngSwitchCase="15"> <!-- UserNotificationType.ABUSE_STATE_CHANGE -->
|
||||||
<my-global-icon iconName="flag" aria-hidden="true"></my-global-icon>
|
<my-global-icon iconName="flag" aria-hidden="true"></my-global-icon>
|
||||||
|
|
||||||
<div class="message" i18n>
|
<div class="message" i18n>
|
||||||
|
@ -73,7 +73,7 @@
|
||||||
</div>
|
</div>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<ng-container *ngSwitchCase="UserNotificationType.ABUSE_NEW_MESSAGE">
|
<ng-container *ngSwitchCase="16"> <!-- UserNotificationType.ABUSE_NEW_MESSAGE -->
|
||||||
<my-global-icon iconName="flag" aria-hidden="true"></my-global-icon>
|
<my-global-icon iconName="flag" aria-hidden="true"></my-global-icon>
|
||||||
|
|
||||||
<div class="message" i18n>
|
<div class="message" i18n>
|
||||||
|
@ -81,7 +81,7 @@
|
||||||
</div>
|
</div>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<ng-container *ngSwitchCase="UserNotificationType.VIDEO_AUTO_BLACKLIST_FOR_MODERATORS">
|
<ng-container *ngSwitchCase="12"> <!-- UserNotificationType.VIDEO_AUTO_BLACKLIST_FOR_MODERATORS -->
|
||||||
<my-global-icon iconName="no" aria-hidden="true"></my-global-icon>
|
<my-global-icon iconName="no" aria-hidden="true"></my-global-icon>
|
||||||
|
|
||||||
<div class="message" i18n>
|
<div class="message" i18n>
|
||||||
|
@ -89,7 +89,7 @@
|
||||||
</div>
|
</div>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<ng-container *ngSwitchCase="UserNotificationType.NEW_COMMENT_ON_MY_VIDEO">
|
<ng-container *ngSwitchCase="2">
|
||||||
<ng-container *ngIf="notification.comment">
|
<ng-container *ngIf="notification.comment">
|
||||||
<a (click)="markAsRead(notification)" [routerLink]="notification.accountUrl">
|
<a (click)="markAsRead(notification)" [routerLink]="notification.accountUrl">
|
||||||
<img alt="" aria-labelledby="avatar" class="avatar" [src]="notification.comment.account.avatarUrl" />
|
<img alt="" aria-labelledby="avatar" class="avatar" [src]="notification.comment.account.avatarUrl" />
|
||||||
|
@ -109,7 +109,7 @@
|
||||||
</ng-container>
|
</ng-container>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<ng-container *ngSwitchCase="UserNotificationType.MY_VIDEO_PUBLISHED">
|
<ng-container *ngSwitchCase="6"> <!-- UserNotificationType.MY_VIDEO_PUBLISHED -->
|
||||||
<my-global-icon iconName="film" aria-hidden="true"></my-global-icon>
|
<my-global-icon iconName="film" aria-hidden="true"></my-global-icon>
|
||||||
|
|
||||||
<div class="message" i18n>
|
<div class="message" i18n>
|
||||||
|
@ -117,7 +117,7 @@
|
||||||
</div>
|
</div>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<ng-container *ngSwitchCase="UserNotificationType.MY_VIDEO_IMPORT_SUCCESS">
|
<ng-container *ngSwitchCase="7"> <!-- UserNotificationType.MY_VIDEO_IMPORT_SUCCESS -->
|
||||||
<my-global-icon iconName="cloud-download" aria-hidden="true"></my-global-icon>
|
<my-global-icon iconName="cloud-download" aria-hidden="true"></my-global-icon>
|
||||||
|
|
||||||
<div class="message" i18n>
|
<div class="message" i18n>
|
||||||
|
@ -125,7 +125,7 @@
|
||||||
</div>
|
</div>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<ng-container *ngSwitchCase="UserNotificationType.MY_VIDEO_IMPORT_ERROR">
|
<ng-container *ngSwitchCase="8"> <!-- UserNotificationType.MY_VIDEO_IMPORT_ERROR -->
|
||||||
<my-global-icon iconName="cloud-error" aria-hidden="true"></my-global-icon>
|
<my-global-icon iconName="cloud-error" aria-hidden="true"></my-global-icon>
|
||||||
|
|
||||||
<div class="message" i18n>
|
<div class="message" i18n>
|
||||||
|
@ -133,7 +133,7 @@
|
||||||
</div>
|
</div>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<ng-container *ngSwitchCase="UserNotificationType.NEW_USER_REGISTRATION">
|
<ng-container *ngSwitchCase="9"> <!-- UserNotificationType.NEW_USER_REGISTRATION -->
|
||||||
<my-global-icon iconName="user-add" aria-hidden="true"></my-global-icon>
|
<my-global-icon iconName="user-add" aria-hidden="true"></my-global-icon>
|
||||||
|
|
||||||
<div class="message" i18n>
|
<div class="message" i18n>
|
||||||
|
@ -141,7 +141,7 @@
|
||||||
</div>
|
</div>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<ng-container *ngSwitchCase="UserNotificationType.NEW_FOLLOW">
|
<ng-container *ngSwitchCase="10"> <!-- UserNotificationType.NEW_FOLLOW -->
|
||||||
<a (click)="markAsRead(notification)" [routerLink]="notification.accountUrl">
|
<a (click)="markAsRead(notification)" [routerLink]="notification.accountUrl">
|
||||||
<img alt="" aria-labelledby="avatar" class="avatar" [src]="notification.actorFollow.follower.avatarUrl" />
|
<img alt="" aria-labelledby="avatar" class="avatar" [src]="notification.actorFollow.follower.avatarUrl" />
|
||||||
</a>
|
</a>
|
||||||
|
@ -154,7 +154,7 @@
|
||||||
</div>
|
</div>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<ng-container *ngSwitchCase="UserNotificationType.COMMENT_MENTION">
|
<ng-container *ngSwitchCase="11">
|
||||||
<ng-container *ngIf="notification.comment">
|
<ng-container *ngIf="notification.comment">
|
||||||
<a (click)="markAsRead(notification)" [routerLink]="notification.accountUrl">
|
<a (click)="markAsRead(notification)" [routerLink]="notification.accountUrl">
|
||||||
<img alt="" aria-labelledby="avatar" class="avatar" [src]="notification.comment.account.avatarUrl" />
|
<img alt="" aria-labelledby="avatar" class="avatar" [src]="notification.comment.account.avatarUrl" />
|
||||||
|
@ -174,7 +174,7 @@
|
||||||
</ng-container>
|
</ng-container>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<ng-container *ngSwitchCase="UserNotificationType.NEW_INSTANCE_FOLLOWER">
|
<ng-container *ngSwitchCase="13"> <!-- UserNotificationType.NEW_INSTANCE_FOLLOWER -->
|
||||||
<my-global-icon iconName="users" aria-hidden="true"></my-global-icon>
|
<my-global-icon iconName="users" aria-hidden="true"></my-global-icon>
|
||||||
|
|
||||||
<div class="message" i18n>
|
<div class="message" i18n>
|
||||||
|
@ -183,7 +183,7 @@
|
||||||
</div>
|
</div>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<ng-container *ngSwitchCase="UserNotificationType.AUTO_INSTANCE_FOLLOWING">
|
<ng-container *ngSwitchCase="14"> <!-- UserNotificationType.AUTO_INSTANCE_FOLLOWING -->
|
||||||
<my-global-icon iconName="users" aria-hidden="true"></my-global-icon>
|
<my-global-icon iconName="users" aria-hidden="true"></my-global-icon>
|
||||||
|
|
||||||
<div class="message" i18n>
|
<div class="message" i18n>
|
||||||
|
|
|
@ -21,9 +21,6 @@ export class UserNotificationsComponent implements OnInit {
|
||||||
notifications: UserNotification[] = []
|
notifications: UserNotification[] = []
|
||||||
sortField = 'createdAt'
|
sortField = 'createdAt'
|
||||||
|
|
||||||
// So we can access it in the template
|
|
||||||
UserNotificationType = UserNotificationType
|
|
||||||
|
|
||||||
componentPagination: ComponentPagination
|
componentPagination: ComponentPagination
|
||||||
|
|
||||||
onDataSubject = new Subject<any[]>()
|
onDataSubject = new Subject<any[]>()
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
import { exists } from './misc'
|
|
||||||
import validator from 'validator'
|
import validator from 'validator'
|
||||||
import { UserNotificationType } from '../../../shared/models/users'
|
|
||||||
import { UserNotificationSettingValue } from '../../../shared/models/users/user-notification-setting.model'
|
import { UserNotificationSettingValue } from '../../../shared/models/users/user-notification-setting.model'
|
||||||
|
import { exists } from './misc'
|
||||||
|
|
||||||
function isUserNotificationTypeValid (value: any) {
|
function isUserNotificationTypeValid (value: any) {
|
||||||
return exists(value) && validator.isInt('' + value) && UserNotificationType[value] !== undefined
|
return exists(value) && validator.isInt('' + value)
|
||||||
}
|
}
|
||||||
|
|
||||||
function isUserNotificationSettingValid (value: any) {
|
function isUserNotificationSettingValid (value: any) {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { FollowState } from '../actors'
|
import { FollowState } from '../actors'
|
||||||
import { AbuseState } from '../moderation'
|
import { AbuseState } from '../moderation'
|
||||||
|
|
||||||
export enum UserNotificationType {
|
export const enum UserNotificationType {
|
||||||
NEW_VIDEO_FROM_SUBSCRIPTION = 1,
|
NEW_VIDEO_FROM_SUBSCRIPTION = 1,
|
||||||
NEW_COMMENT_ON_MY_VIDEO = 2,
|
NEW_COMMENT_ON_MY_VIDEO = 2,
|
||||||
NEW_ABUSE_FOR_MODERATORS = 3,
|
NEW_ABUSE_FOR_MODERATORS = 3,
|
||||||
|
|
Loading…
Reference in New Issue