From f166efb009b52603848252f4239a501599b10baa Mon Sep 17 00:00:00 2001 From: Derek P Sifford Date: Wed, 23 Aug 2017 16:52:30 -0400 Subject: [PATCH] fix: refresh reference list issue This fixes an issue caused by the `pruneOrphanedCitations` method in the `store.ts` not being able to handle cases where there are more than 1 orphaned citation in the document at a time. Closes #303 --- src/js/reference-list/store.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/js/reference-list/store.ts b/src/js/reference-list/store.ts index 10f31157..cd963c2d 100644 --- a/src/js/reference-list/store.ts +++ b/src/js/reference-list/store.ts @@ -145,9 +145,9 @@ class CitationStore { */ @action pruneOrphanedCitations(citationIds: string[]): void { - if (this.byIndex.length === citationIds.length) return; - const index = this.byIndex.findIndex(a => !citationIds.includes(a.citationID!)); - this.byIndex.replace([...this.byIndex.slice(0, index), ...this.byIndex.slice(index + 1)]); + this.byIndex.replace( + this.byIndex.filter(citation => citationIds.includes(citation.citationID!)), + ); } /**