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 contact creation #311

Merged
merged 2 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions scripts/remove-purposes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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)
}
Expand Down
5 changes: 3 additions & 2 deletions src/components/Providers/ContactToPlaceProvider.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 (
<ContactToPlaceContext.Provider value={value}>
Expand Down