From f7dc174e61313601d16e47db9828c71ae17b3b9f Mon Sep 17 00:00:00 2001 From: MillenniumEarl Date: Wed, 3 Mar 2021 20:14:56 +0100 Subject: [PATCH] Add fallback for missing rating --- src/scripts/classes/mapping/thread.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/scripts/classes/mapping/thread.ts b/src/scripts/classes/mapping/thread.ts index 6da482d..ff593af 100644 --- a/src/scripts/classes/mapping/thread.ts +++ b/src/scripts/classes/mapping/thread.ts @@ -173,9 +173,9 @@ export default class Thread { private parseRating(data: TJsonLD): TRating { const ratingTree = data["aggregateRating"] as TJsonLD; const rating: TRating = { - average: parseFloat(ratingTree["ratingValue"] as string), - best: parseInt(ratingTree["bestRating"] as string), - count: parseInt(ratingTree["ratingCount"] as string), + average: ratingTree ? parseFloat(ratingTree["ratingValue"] as string) : 0, + best: ratingTree ? parseInt(ratingTree["bestRating"] as string) : 0, + count: ratingTree ? parseInt(ratingTree["ratingCount"] as string) : 0, }; return rating;