Skip to content

Commit

Permalink
Merge pull request #4575 from broadinstitute/saved-search-identity
Browse files Browse the repository at this point in the history
better identity check for saved searches with gene list
  • Loading branch information
hanars authored Jan 8, 2025
2 parents 2d8092a + 407f813 commit 117ed33
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion ui/pages/Search/components/SavedSearch.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react'
import isEqual from 'lodash/isEqual'
import PropTypes from 'prop-types'
import { connect } from 'react-redux'
import { FormSpy } from 'react-final-form'
Expand Down Expand Up @@ -31,11 +32,17 @@ const FormButtonContainer = styled.div`

const SUBSCRIPTION = { values: true }

const isSameSearch = ({ locus: locus1, ...search1 }, { locus: locus2, ...search2 }) => (
isEqual(search1, search2) && (
locus1?.locusListGuid ? locus1.locusListGuid === locus2.locusListGuid : isEqual(locus1, locus2)
)
)

const CurrentSavedSearchProvider = ({ element, ...props }) => (
<FormSpy subscription={SUBSCRIPTION}>
{({ values }) => {
const currentSavedSearch = values.search && Object.values(props.savedSearchesByGuid).find(
({ search }) => search === values.search,
({ search }) => isSameSearch(search, values.search),
)
return React.createElement(element, { currentSavedSearch, search: values.search, ...props })
}}
Expand Down

0 comments on commit 117ed33

Please sign in to comment.