Add fallback for missing rating

pull/73/head
MillenniumEarl 2021-03-03 20:14:56 +01:00
parent 7dcb49c6a5
commit f7dc174e61
1 changed files with 3 additions and 3 deletions

View File

@ -173,9 +173,9 @@ export default class Thread {
private parseRating(data: TJsonLD): TRating { private parseRating(data: TJsonLD): TRating {
const ratingTree = data["aggregateRating"] as TJsonLD; const ratingTree = data["aggregateRating"] as TJsonLD;
const rating: TRating = { const rating: TRating = {
average: parseFloat(ratingTree["ratingValue"] as string), average: ratingTree ? parseFloat(ratingTree["ratingValue"] as string) : 0,
best: parseInt(ratingTree["bestRating"] as string), best: ratingTree ? parseInt(ratingTree["bestRating"] as string) : 0,
count: parseInt(ratingTree["ratingCount"] as string), count: ratingTree ? parseInt(ratingTree["ratingCount"] as string) : 0,
}; };
return rating; return rating;