aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2023-08-21 15:32:33 +0200
committerChocobozzz <me@florianbigard.com>2023-08-21 15:32:33 +0200
commit4d3ea87486e095aa7934888b66443cfce6804894 (patch)
treeb453038de21fae220124e542db85e41f8aa1a059
parentab5f1356b9fbc575cb0b126ca21bb809a6475089 (diff)
downloadPeerTube-4d3ea87486e095aa7934888b66443cfce6804894.tar.gz
PeerTube-4d3ea87486e095aa7934888b66443cfce6804894.tar.zst
PeerTube-4d3ea87486e095aa7934888b66443cfce6804894.zip
More robust about page
Don't throw if we can't find a category or a language Can happen if the instance configuration contains a category/language that has been deleted by a plugin for example
-rw-r--r--client/src/app/shared/shared-instance/instance.service.ts25
1 files changed, 17 insertions, 8 deletions
diff --git a/client/src/app/shared/shared-instance/instance.service.ts b/client/src/app/shared/shared-instance/instance.service.ts
index 9a55cf972..58bf8ee54 100644
--- a/client/src/app/shared/shared-instance/instance.service.ts
+++ b/client/src/app/shared/shared-instance/instance.service.ts
@@ -6,6 +6,7 @@ import { MarkdownService, RestExtractor, ServerService } from '@app/core'
6import { objectKeysTyped, peertubeTranslate } from '@peertube/peertube-core-utils' 6import { objectKeysTyped, peertubeTranslate } from '@peertube/peertube-core-utils'
7import { About } from '@peertube/peertube-models' 7import { About } from '@peertube/peertube-models'
8import { environment } from '../../../environments/environment' 8import { environment } from '../../../environments/environment'
9import { logger } from '@root-helpers/logger'
9 10
10export type AboutHTML = Pick<About['instance'], 11export type AboutHTML = Pick<About['instance'],
11'terms' | 'codeOfConduct' | 'moderationInformation' | 'administrator' | 'creationReason' | 12'terms' | 'codeOfConduct' | 'moderationInformation' | 'administrator' | 'creationReason' |
@@ -69,11 +70,15 @@ export class InstanceService {
69 ]).pipe( 70 ]).pipe(
70 map(([ languagesArray, translations ]) => { 71 map(([ languagesArray, translations ]) => {
71 return about.instance.languages 72 return about.instance.languages
72 .map(l => { 73 .map(l => {
73 const languageObj = languagesArray.find(la => la.id === l) 74 const languageObj = languagesArray.find(la => la.id === l)
75 if (!languageObj) {
76 logger.error(`Cannot find language ${l} in available languages`)
77 return ''
78 }
74 79
75 return peertubeTranslate(languageObj.label, translations) 80 return peertubeTranslate(languageObj.label, translations)
76 }) 81 })
77 }) 82 })
78 ) 83 )
79 } 84 }
@@ -85,11 +90,15 @@ export class InstanceService {
85 ]).pipe( 90 ]).pipe(
86 map(([ categoriesArray, translations ]) => { 91 map(([ categoriesArray, translations ]) => {
87 return about.instance.categories 92 return about.instance.categories
88 .map(c => { 93 .map(c => {
89 const categoryObj = categoriesArray.find(ca => ca.id === c) 94 const categoryObj = categoriesArray.find(ca => ca.id === c)
95 if (!categoryObj) {
96 logger.error(`Cannot find instance category ${c} in available categories`)
97 return ''
98 }
90 99
91 return peertubeTranslate(categoryObj.label, translations) 100 return peertubeTranslate(categoryObj.label, translations)
92 }) 101 })
93 }) 102 })
94 ) 103 )
95 } 104 }