diff --git a/scripts/apps/archive/directives/RelatedItemsPreview.ts b/scripts/apps/archive/directives/RelatedItemsPreview.ts index c6479e3f31..35e0d4e378 100644 --- a/scripts/apps/archive/directives/RelatedItemsPreview.ts +++ b/scripts/apps/archive/directives/RelatedItemsPreview.ts @@ -1,6 +1,7 @@ import {IArticle, IArticleField, IRendition} from 'superdesk-api'; import {gettext} from 'core/utils'; import {getThumbnailForItem} from 'core/helpers/item'; +import {throttle} from 'lodash'; /** * @ngdoc directive @@ -38,11 +39,19 @@ export function RelatedItemsPreview(relationsService) { scope.gettext = gettext; scope.getThumbnailForItem = getThumbnailForItem; - relationsService.getRelatedItemsForField(scope.item, scope.field._id) - .then((items) => { - scope.relatedItems = items; - scope.loading = false; - }); + // Define the throttled function + const getRelatedItems = throttle((item) => { + relationsService.getRelatedItemsForField(item, scope.field._id) + .then((items) => { + scope.relatedItems = items; + scope.loading = false; + }); + }, 1000); + + scope.$watch('item', (item) => { + scope.loading = true; + getRelatedItems(item); + }); }, }; }