Skip to content

Commit

Permalink
Merge pull request #546 from coasys/Bug-fix--allEntries-re-added-to-l…
Browse files Browse the repository at this point in the history
…inkAdded-function-in-useSubjects-hook

Bug fix: allEntries readded to linkAdded function in useSubjects hook
  • Loading branch information
lucksus authored Dec 20, 2024
2 parents de19467 + 82b781a commit a92421e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions ad4m-hooks/react/src/useSubjects.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export function useSubjects<SubjectClass>(props: Props<SubjectClass>) {

const newEntries = isOldEntry
? oldEntries?.map((oldEntry) => {
// @ts-ignore
// @ts-ignore
const isUpdatedEntry = id === oldEntry.id;
return isUpdatedEntry ? entry : oldEntry;
})
Expand All @@ -97,8 +97,8 @@ export function useSubjects<SubjectClass>(props: Props<SubjectClass>) {
timeout.current = setTimeout(getData, 1000);

const isNewEntry = link.data.source === source;
// @ts-ignore
const isUpdated = allEntries?.find((e) => e.id === link.data.source);
const allEntries = (getCache(cacheKey) || []) as SubjectClass[];
const isUpdated = allEntries?.find((e: any) => e.id === link.data.source);

const id = isNewEntry
? link.data.target
Expand Down

0 comments on commit a92421e

Please sign in to comment.