aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-02-14 10:07:25 +0100
committerChocobozzz <me@florianbigard.com>2019-02-15 09:43:36 +0100
commit344d8be566a1e857f8622e850973817eac768b3e (patch)
tree9cc6ab6472098c4bf1409b3b937ed7de20572976 /client/src/app
parent285e04f6ddacae90274a0a1d541ce1c4c8df09b5 (diff)
downloadPeerTube-344d8be566a1e857f8622e850973817eac768b3e.tar.gz
PeerTube-344d8be566a1e857f8622e850973817eac768b3e.tar.zst
PeerTube-344d8be566a1e857f8622e850973817eac768b3e.zip
Don't crash on error in notification popup
Diffstat (limited to 'client/src/app')
-rw-r--r--client/src/app/shared/users/user-notification.model.ts140
1 files changed, 73 insertions, 67 deletions
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 {
63 this.type = hash.type 63 this.type = hash.type
64 this.read = hash.read 64 this.read = hash.read
65 65
66 this.video = hash.video 66 // We assume that some fields exist
67 if (this.video) this.setAvatarUrl(this.video.channel) 67 // To prevent a notification popup crash in case of bug, wrap it inside a try/catch
68 68 try {
69 this.videoImport = hash.videoImport 69 this.video = hash.video
70 70 if (this.video) this.setAvatarUrl(this.video.channel)
71 this.comment = hash.comment 71
72 if (this.comment) this.setAvatarUrl(this.comment.account) 72 this.videoImport = hash.videoImport
73 73
74 this.videoAbuse = hash.videoAbuse 74 this.comment = hash.comment
75 75 if (this.comment) this.setAvatarUrl(this.comment.account)
76 this.videoBlacklist = hash.videoBlacklist 76
77 77 this.videoAbuse = hash.videoAbuse
78 this.account = hash.account 78
79 if (this.account) this.setAvatarUrl(this.account) 79 this.videoBlacklist = hash.videoBlacklist
80 80
81 this.actorFollow = hash.actorFollow 81 this.account = hash.account
82 if (this.actorFollow) this.setAvatarUrl(this.actorFollow.follower) 82 if (this.account) this.setAvatarUrl(this.account)
83 83
84 this.createdAt = hash.createdAt 84 this.actorFollow = hash.actorFollow
85 this.updatedAt = hash.updatedAt 85 if (this.actorFollow) this.setAvatarUrl(this.actorFollow.follower)
86 86
87 switch (this.type) { 87 this.createdAt = hash.createdAt
88 case UserNotificationType.NEW_VIDEO_FROM_SUBSCRIPTION: 88 this.updatedAt = hash.updatedAt
89 this.videoUrl = this.buildVideoUrl(this.video) 89
90 break 90 switch (this.type) {
91 91 case UserNotificationType.NEW_VIDEO_FROM_SUBSCRIPTION:
92 case UserNotificationType.UNBLACKLIST_ON_MY_VIDEO: 92 this.videoUrl = this.buildVideoUrl(this.video)
93 this.videoUrl = this.buildVideoUrl(this.video) 93 break
94 break 94
95 95 case UserNotificationType.UNBLACKLIST_ON_MY_VIDEO:
96 case UserNotificationType.NEW_COMMENT_ON_MY_VIDEO: 96 this.videoUrl = this.buildVideoUrl(this.video)
97 case UserNotificationType.COMMENT_MENTION: 97 break
98 this.accountUrl = this.buildAccountUrl(this.comment.account) 98
99 this.commentUrl = [ this.buildVideoUrl(this.comment.video), { threadId: this.comment.threadId } ] 99 case UserNotificationType.NEW_COMMENT_ON_MY_VIDEO:
100 break 100 case UserNotificationType.COMMENT_MENTION:
101 101 this.accountUrl = this.buildAccountUrl(this.comment.account)
102 case UserNotificationType.NEW_VIDEO_ABUSE_FOR_MODERATORS: 102 this.commentUrl = [ this.buildVideoUrl(this.comment.video), { threadId: this.comment.threadId } ]
103 this.videoAbuseUrl = '/admin/moderation/video-abuses/list' 103 break
104 this.videoUrl = this.buildVideoUrl(this.videoAbuse.video) 104
105 break 105 case UserNotificationType.NEW_VIDEO_ABUSE_FOR_MODERATORS:
106 106 this.videoAbuseUrl = '/admin/moderation/video-abuses/list'
107 case UserNotificationType.BLACKLIST_ON_MY_VIDEO: 107 this.videoUrl = this.buildVideoUrl(this.videoAbuse.video)
108 this.videoUrl = this.buildVideoUrl(this.videoBlacklist.video) 108 break
109 break 109
110 110 case UserNotificationType.BLACKLIST_ON_MY_VIDEO:
111 case UserNotificationType.MY_VIDEO_PUBLISHED: 111 this.videoUrl = this.buildVideoUrl(this.videoBlacklist.video)
112 this.videoUrl = this.buildVideoUrl(this.video) 112 break
113 break 113
114 114 case UserNotificationType.MY_VIDEO_PUBLISHED:
115 case UserNotificationType.MY_VIDEO_IMPORT_SUCCESS: 115 this.videoUrl = this.buildVideoUrl(this.video)
116 this.videoImportUrl = this.buildVideoImportUrl() 116 break
117 this.videoImportIdentifier = this.buildVideoImportIdentifier(this.videoImport) 117
118 this.videoUrl = this.buildVideoUrl(this.videoImport.video) 118 case UserNotificationType.MY_VIDEO_IMPORT_SUCCESS:
119 break 119 this.videoImportUrl = this.buildVideoImportUrl()
120 120 this.videoImportIdentifier = this.buildVideoImportIdentifier(this.videoImport)
121 case UserNotificationType.MY_VIDEO_IMPORT_ERROR: 121 this.videoUrl = this.buildVideoUrl(this.videoImport.video)
122 this.videoImportUrl = this.buildVideoImportUrl() 122 break
123 this.videoImportIdentifier = this.buildVideoImportIdentifier(this.videoImport) 123
124 break 124 case UserNotificationType.MY_VIDEO_IMPORT_ERROR:
125 125 this.videoImportUrl = this.buildVideoImportUrl()
126 case UserNotificationType.NEW_USER_REGISTRATION: 126 this.videoImportIdentifier = this.buildVideoImportIdentifier(this.videoImport)
127 this.accountUrl = this.buildAccountUrl(this.account) 127 break
128 break 128
129 129 case UserNotificationType.NEW_USER_REGISTRATION:
130 case UserNotificationType.NEW_FOLLOW: 130 this.accountUrl = this.buildAccountUrl(this.account)
131 this.accountUrl = this.buildAccountUrl(this.actorFollow.follower) 131 break
132 break 132
133 case UserNotificationType.NEW_FOLLOW:
134 this.accountUrl = this.buildAccountUrl(this.actorFollow.follower)
135 break
136 }
137 } catch (err) {
138 console.error(err)
133 } 139 }
134 } 140 }
135 141