From 9b69bfc076a5d867fbf5142f31840407d5a7aeae Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 14 Feb 2019 10:07:25 +0100 Subject: Don't crash on error in notification popup --- .../app/shared/users/user-notification.model.ts | 140 +++++++++++---------- 1 file changed, 73 insertions(+), 67 deletions(-) (limited to 'client') diff --git a/client/src/app/shared/users/user-notification.model.ts b/client/src/app/shared/users/user-notification.model.ts index 125d2120c..5d0dc19ae 100644 --- a/client/src/app/shared/users/user-notification.model.ts +++ b/client/src/app/shared/users/user-notification.model.ts @@ -63,73 +63,79 @@ export class UserNotification implements UserNotificationServer { this.type = hash.type this.read = hash.read - this.video = hash.video - if (this.video) this.setAvatarUrl(this.video.channel) - - this.videoImport = hash.videoImport - - this.comment = hash.comment - if (this.comment) this.setAvatarUrl(this.comment.account) - - this.videoAbuse = hash.videoAbuse - - this.videoBlacklist = hash.videoBlacklist - - this.account = hash.account - if (this.account) this.setAvatarUrl(this.account) - - this.actorFollow = hash.actorFollow - if (this.actorFollow) this.setAvatarUrl(this.actorFollow.follower) - - this.createdAt = hash.createdAt - this.updatedAt = hash.updatedAt - - switch (this.type) { - case UserNotificationType.NEW_VIDEO_FROM_SUBSCRIPTION: - this.videoUrl = this.buildVideoUrl(this.video) - break - - case UserNotificationType.UNBLACKLIST_ON_MY_VIDEO: - this.videoUrl = this.buildVideoUrl(this.video) - break - - case UserNotificationType.NEW_COMMENT_ON_MY_VIDEO: - case UserNotificationType.COMMENT_MENTION: - this.accountUrl = this.buildAccountUrl(this.comment.account) - this.commentUrl = [ this.buildVideoUrl(this.comment.video), { threadId: this.comment.threadId } ] - break - - case UserNotificationType.NEW_VIDEO_ABUSE_FOR_MODERATORS: - this.videoAbuseUrl = '/admin/moderation/video-abuses/list' - this.videoUrl = this.buildVideoUrl(this.videoAbuse.video) - break - - case UserNotificationType.BLACKLIST_ON_MY_VIDEO: - this.videoUrl = this.buildVideoUrl(this.videoBlacklist.video) - break - - case UserNotificationType.MY_VIDEO_PUBLISHED: - this.videoUrl = this.buildVideoUrl(this.video) - break - - case UserNotificationType.MY_VIDEO_IMPORT_SUCCESS: - this.videoImportUrl = this.buildVideoImportUrl() - this.videoImportIdentifier = this.buildVideoImportIdentifier(this.videoImport) - this.videoUrl = this.buildVideoUrl(this.videoImport.video) - break - - case UserNotificationType.MY_VIDEO_IMPORT_ERROR: - this.videoImportUrl = this.buildVideoImportUrl() - this.videoImportIdentifier = this.buildVideoImportIdentifier(this.videoImport) - break - - case UserNotificationType.NEW_USER_REGISTRATION: - this.accountUrl = this.buildAccountUrl(this.account) - break - - case UserNotificationType.NEW_FOLLOW: - this.accountUrl = this.buildAccountUrl(this.actorFollow.follower) - break + // We assume that some fields exist + // To prevent a notification popup crash in case of bug, wrap it inside a try/catch + try { + this.video = hash.video + if (this.video) this.setAvatarUrl(this.video.channel) + + this.videoImport = hash.videoImport + + this.comment = hash.comment + if (this.comment) this.setAvatarUrl(this.comment.account) + + this.videoAbuse = hash.videoAbuse + + this.videoBlacklist = hash.videoBlacklist + + this.account = hash.account + if (this.account) this.setAvatarUrl(this.account) + + this.actorFollow = hash.actorFollow + if (this.actorFollow) this.setAvatarUrl(this.actorFollow.follower) + + this.createdAt = hash.createdAt + this.updatedAt = hash.updatedAt + + switch (this.type) { + case UserNotificationType.NEW_VIDEO_FROM_SUBSCRIPTION: + this.videoUrl = this.buildVideoUrl(this.video) + break + + case UserNotificationType.UNBLACKLIST_ON_MY_VIDEO: + this.videoUrl = this.buildVideoUrl(this.video) + break + + case UserNotificationType.NEW_COMMENT_ON_MY_VIDEO: + case UserNotificationType.COMMENT_MENTION: + this.accountUrl = this.buildAccountUrl(this.comment.account) + this.commentUrl = [ this.buildVideoUrl(this.comment.video), { threadId: this.comment.threadId } ] + break + + case UserNotificationType.NEW_VIDEO_ABUSE_FOR_MODERATORS: + this.videoAbuseUrl = '/admin/moderation/video-abuses/list' + this.videoUrl = this.buildVideoUrl(this.videoAbuse.video) + break + + case UserNotificationType.BLACKLIST_ON_MY_VIDEO: + this.videoUrl = this.buildVideoUrl(this.videoBlacklist.video) + break + + case UserNotificationType.MY_VIDEO_PUBLISHED: + this.videoUrl = this.buildVideoUrl(this.video) + break + + case UserNotificationType.MY_VIDEO_IMPORT_SUCCESS: + this.videoImportUrl = this.buildVideoImportUrl() + this.videoImportIdentifier = this.buildVideoImportIdentifier(this.videoImport) + this.videoUrl = this.buildVideoUrl(this.videoImport.video) + break + + case UserNotificationType.MY_VIDEO_IMPORT_ERROR: + this.videoImportUrl = this.buildVideoImportUrl() + this.videoImportIdentifier = this.buildVideoImportIdentifier(this.videoImport) + break + + case UserNotificationType.NEW_USER_REGISTRATION: + this.accountUrl = this.buildAccountUrl(this.account) + break + + case UserNotificationType.NEW_FOLLOW: + this.accountUrl = this.buildAccountUrl(this.actorFollow.follower) + break + } + } catch (err) { + console.error(err) } } -- cgit v1.2.3 From bf12db2497689cb3fcf648ef6fc07a699d1b20d8 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 14 Feb 2019 10:22:10 +0100 Subject: Fix moderators that cannot access the muted servers table --- client/src/app/+admin/moderation/moderation.routes.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'client') diff --git a/client/src/app/+admin/moderation/moderation.routes.ts b/client/src/app/+admin/moderation/moderation.routes.ts index bc6dd49d5..6f6dde290 100644 --- a/client/src/app/+admin/moderation/moderation.routes.ts +++ b/client/src/app/+admin/moderation/moderation.routes.ts @@ -64,7 +64,7 @@ export const ModerationRoutes: Routes = [ component: InstanceServerBlocklistComponent, canActivate: [ UserRightGuard ], data: { - userRight: UserRight.MANAGE_SERVER_REDUNDANCY, + userRight: UserRight.MANAGE_SERVERS_BLOCKLIST, meta: { title: 'Muted instances' } -- cgit v1.2.3 From d4804eead75bfaf41c3150d19e380ff4229d6226 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 14 Feb 2019 11:32:18 +0100 Subject: Fix too long name in menu --- client/src/app/menu/menu.component.html | 4 ++-- client/src/app/menu/menu.component.scss | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'client') diff --git a/client/src/app/menu/menu.component.html b/client/src/app/menu/menu.component.html index aa5bfa9c9..1e532ec13 100644 --- a/client/src/app/menu/menu.component.html +++ b/client/src/app/menu/menu.component.html @@ -5,8 +5,8 @@
- {{ user.account?.displayName }} -
{{ user.username }}
+ {{ user.account?.displayName }} +
{{ user.username }}
diff --git a/client/src/app/menu/menu.component.scss b/client/src/app/menu/menu.component.scss index f30b89413..69704674a 100644 --- a/client/src/app/menu/menu.component.scss +++ b/client/src/app/menu/menu.component.scss @@ -41,8 +41,11 @@ menu { .logged-in-info { flex-grow: 1; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; - .logged-in-username { + .logged-in-display-name { font-size: 16px; font-weight: $font-semibold; color: var(--menuForegroundColor); @@ -51,7 +54,7 @@ menu { @include disable-default-a-behaviour; } - .logged-in-email { + .logged-in-username { font-size: 13px; color: #C6C6C6; white-space: nowrap; -- cgit v1.2.3 From 340f31ce96c456942fb01800f31d795e0f355d74 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 14 Feb 2019 12:41:55 +0100 Subject: Bumped to version v1.2.1 --- client/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'client') diff --git a/client/package.json b/client/package.json index 31fc77887..bc06fbd1c 100644 --- a/client/package.json +++ b/client/package.json @@ -1,6 +1,6 @@ { "name": "peertube-client", - "version": "1.2.0", + "version": "1.2.1", "private": true, "licence": "GPLv3", "author": { -- cgit v1.2.3