Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): ExplorerDocNode no longer displays links multiple times #10233

Open
wants to merge 1 commit into
base: canary
Choose a base branch
from

Conversation

Demohstens
Copy link

Fixes #8522 by creating a new memoized and filtered array of unique linked docs and iterating over the uniqueChildren when creating the Linked ExplorerDocNodes.

Potential issue with Speed: Using a Set might be faster. Especially with large lists of links.

It might be more "elegant" to directly edit the children coming instead of hooking into the changes to children. But I am not very comfortable with the LiveData class so I'm hesitant to use it here. The solution below does work, though.

Version within the children assignment
  const children = useLiveData(
    useMemo(
      () => {
        const data = LiveData.from(
          !collapsed ? docsSearchService.watchRefsFrom(docId) : NEVER,
          null
        )
        return data.map(v => v?.filter(
          (child, index, self) =>
            index === self.findIndex(c => c.docId === child.docId)
          
        )) 
       }, [docsSearchService, docId, collapsed]
    )
  );

@graphite-app graphite-app bot requested review from a team February 17, 2025 22:08
Copy link

graphite-app bot commented Feb 17, 2025

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

​Linked docs can be linked multiple times.
1 participant