diff --git a/scripts/remove-purposes.js b/scripts/remove-purposes.js index 53d0c4ca..93d2d6b8 100644 --- a/scripts/remove-purposes.js +++ b/scripts/remove-purposes.js @@ -9,6 +9,7 @@ const main = async () => { parser.addArgument('--only-automatic-purposes', { defaultValue: false }) parser.addArgument('--from-date', { defaultValue: null }) parser.addArgument('--remove-recurring', { defaultValue: true }) + parser.addArgument('--remove-relationships', { defaultValue: false }) const args = parser.parseArgs() const client = await createClientInteractive({ @@ -52,6 +53,10 @@ const main = async () => { delete doc.aggregation.recurring shouldUpdate = true } + if (args.remove_relationships) { + delete doc.relationships + shouldUpdate = true + } if (shouldUpdate) { newDocs.push(doc) } diff --git a/src/components/Providers/ContactToPlaceProvider.jsx b/src/components/Providers/ContactToPlaceProvider.jsx index 4f9bfb35..8a78c0ca 100644 --- a/src/components/Providers/ContactToPlaceProvider.jsx +++ b/src/components/Providers/ContactToPlaceProvider.jsx @@ -30,7 +30,8 @@ const ContactToPlaceProvider = ({ children }) => { const [category, setCategory] = useState() const { timeserie } = useTrip() - const contactId = getRelationshipByType(timeserie, type)?.data?._id || ' ' + const contactId = + getRelationshipByType(timeserie, type)?.data?._id || contact?._id || ' ' const contactsQuery = buildContactsQueryById(contactId) const { data: fetchedContact, ...contactsQueryResult } = useQuery( contactsQuery.definition, @@ -62,7 +63,7 @@ const ContactToPlaceProvider = ({ children }) => { setContact(fetchedContact) setLabel(getLabelByType({ contact: fetchedContact, timeserie, type })) setCategory(getCategoryByType({ contact: fetchedContact, timeserie, type })) - }, [type, fetchedContact?._id, timeserie?._id]) // eslint-disable-line react-hooks/exhaustive-deps + }, [type, fetchedContact?._rev, fetchedContact?._id, timeserie?._id]) // eslint-disable-line react-hooks/exhaustive-deps return (