From a78d0f65f7665eb784e6e2251e54ff48fe34edd6 Mon Sep 17 00:00:00 2001 From: Alan Orth Date: Wed, 25 Sep 2024 08:37:40 +0300 Subject: [PATCH] src/app/item-page: try/catch for Altmetric and Dimensions Use try/catch on Altmetric and Dimensions components to avoid spam about missing window, self, and document in SSR. --- .../altmetric/item-page-altmetric-field.component.ts | 6 +++++- .../dimensions/item-page-dimensions-field.component.ts | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/app/item-page/simple/field-components/specific-field/altmetric/item-page-altmetric-field.component.ts b/src/app/item-page/simple/field-components/specific-field/altmetric/item-page-altmetric-field.component.ts index 4827cc8e4af..f81970f6968 100644 --- a/src/app/item-page/simple/field-components/specific-field/altmetric/item-page-altmetric-field.component.ts +++ b/src/app/item-page/simple/field-components/specific-field/altmetric/item-page-altmetric-field.component.ts @@ -17,7 +17,11 @@ export class ItemPageAltmetricFieldComponent extends ItemPageFieldComponent impl ngAfterViewInit() { // Altmetric embed.js import('./embed.js'); - window['_altmetric_embed_init'](); + try { + window['_altmetric_embed_init'](); + } catch { + + } } /** diff --git a/src/app/item-page/simple/field-components/specific-field/dimensions/item-page-dimensions-field.component.ts b/src/app/item-page/simple/field-components/specific-field/dimensions/item-page-dimensions-field.component.ts index 749aebe2775..15877134356 100644 --- a/src/app/item-page/simple/field-components/specific-field/dimensions/item-page-dimensions-field.component.ts +++ b/src/app/item-page/simple/field-components/specific-field/dimensions/item-page-dimensions-field.component.ts @@ -17,6 +17,12 @@ export class ItemPageDimensionsFieldComponent extends ItemPageFieldComponent imp ngAfterViewInit() { // Dimensions badge.js import('./badge.js'); + + try { + window['__dimensions_embed'].addBadges(); + } catch { + + } } /**