From 31c1f28c5c922cfba09db2fe9eb1df7969e6b4bd Mon Sep 17 00:00:00 2001 From: Luka van der Plas Date: Thu, 19 Sep 2024 14:32:50 +0200 Subject: [PATCH] generalise cache update --- .../episode-entities-form.component.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/frontend/src/app/data-entry/episode-form/episode-entities-form/episode-entities-form.component.ts b/frontend/src/app/data-entry/episode-form/episode-entities-form/episode-entities-form.component.ts index c39a7c54..50541e3d 100644 --- a/frontend/src/app/data-entry/episode-form/episode-entities-form/episode-entities-form.component.ts +++ b/frontend/src/app/data-entry/episode-form/episode-entities-form/episode-entities-form.component.ts @@ -18,8 +18,7 @@ import { splat, differenceBy } from "@shared/utils"; import { ToastService } from "@services/toast.service"; type EntityPropertyName = 'agents' | 'gifts' | 'letters' | 'spaces'; - -const REFETCH_QUERIES = ['DataEntryEpisodeEntities']; +type EntityTypeName = 'AgentDescriptionType' | 'GiftDescriptionType' | 'LetterDescriptionType' | 'SpaceDescriptionType'; let nextID = 0; @@ -97,6 +96,16 @@ export class EpisodeEntitiesFormComponent implements OnChanges, OnDestroy { return keys[this.entityType] } + get entityTypeName(): EntityTypeName { + const types: Record = { + [Entity.Agent]: 'AgentDescriptionType', + [Entity.Gift]: 'GiftDescriptionType', + [Entity.Letter]: 'LetterDescriptionType', + [Entity.Space]: 'SpaceDescriptionType', + } + return types[this.entityType]; + } + ngOnChanges(changes: SimpleChanges): void { if (changes['entityType']) { @@ -173,7 +182,7 @@ export class EpisodeEntitiesFormComponent implements OnChanges, OnDestroy { id: episodeID, })); cache.evict(cache.identify({ - __typename: "AgentDescriptionType", + __typename: this.entityTypeName, id: entityID, })); cache.gc();