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
This commit is contained in:
parent
ab5f1356b9
commit
4d3ea87486
|
@ -6,6 +6,7 @@ import { MarkdownService, RestExtractor, ServerService } from '@app/core'
|
||||||
import { objectKeysTyped, peertubeTranslate } from '@peertube/peertube-core-utils'
|
import { objectKeysTyped, peertubeTranslate } from '@peertube/peertube-core-utils'
|
||||||
import { About } from '@peertube/peertube-models'
|
import { About } from '@peertube/peertube-models'
|
||||||
import { environment } from '../../../environments/environment'
|
import { environment } from '../../../environments/environment'
|
||||||
|
import { logger } from '@root-helpers/logger'
|
||||||
|
|
||||||
export type AboutHTML = Pick<About['instance'],
|
export type AboutHTML = Pick<About['instance'],
|
||||||
'terms' | 'codeOfConduct' | 'moderationInformation' | 'administrator' | 'creationReason' |
|
'terms' | 'codeOfConduct' | 'moderationInformation' | 'administrator' | 'creationReason' |
|
||||||
|
@ -69,11 +70,15 @@ export class InstanceService {
|
||||||
]).pipe(
|
]).pipe(
|
||||||
map(([ languagesArray, translations ]) => {
|
map(([ languagesArray, translations ]) => {
|
||||||
return about.instance.languages
|
return about.instance.languages
|
||||||
.map(l => {
|
.map(l => {
|
||||||
const languageObj = languagesArray.find(la => la.id === l)
|
const languageObj = languagesArray.find(la => la.id === l)
|
||||||
|
if (!languageObj) {
|
||||||
|
logger.error(`Cannot find language ${l} in available languages`)
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
|
||||||
return peertubeTranslate(languageObj.label, translations)
|
return peertubeTranslate(languageObj.label, translations)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -85,11 +90,15 @@ export class InstanceService {
|
||||||
]).pipe(
|
]).pipe(
|
||||||
map(([ categoriesArray, translations ]) => {
|
map(([ categoriesArray, translations ]) => {
|
||||||
return about.instance.categories
|
return about.instance.categories
|
||||||
.map(c => {
|
.map(c => {
|
||||||
const categoryObj = categoriesArray.find(ca => ca.id === c)
|
const categoryObj = categoriesArray.find(ca => ca.id === c)
|
||||||
|
if (!categoryObj) {
|
||||||
|
logger.error(`Cannot find instance category ${c} in available categories`)
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
|
||||||
return peertubeTranslate(categoryObj.label, translations)
|
return peertubeTranslate(categoryObj.label, translations)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user