Skip to content

Commit

Permalink
Commit again
Browse files Browse the repository at this point in the history
  • Loading branch information
kennsippell committed Mar 12, 2024
1 parent 6a17c20 commit d938d0c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/lib/cht-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,11 @@ export class ChtApi {
delete payloadClone.contact;
delete payloadClone.parent;

if (!doc.user_attribution) {
doc.user_attribution = {};
}
(doc.user_attribution.previousPrimaryContacts ||= []).push(doc.contact._id);
const previousPrimaryContact = doc.contact._id;
Object.assign(doc, payloadClone, { contact: { _id: contactId }});
doc.user_attribution ||= {};
doc.user_attribution.previousPrimaryContacts ||= [];
doc.user_attribution.previousPrimaryContacts.push(previousPrimaryContact);

const putUrl = `${this.protocolAndHost}/medic/${payload._id}`;
console.log('axios.put', putUrl);
Expand Down
2 changes: 1 addition & 1 deletion src/services/upload.replacement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class UploadReplacementPlace implements Uploader {
}

const updatedPlaceDoc = await retryOnUpdateConflict<any>(() => this.chtApi.updatePlace(payload, contactId));
const toDelete = updatedPlaceDoc.previousPrimaryContacts?.pop();
const toDelete = updatedPlaceDoc.user_attribution.previousPrimaryContacts?.pop();
if (toDelete) {
await retryOnUpdateConflict<any>(() => this.chtApi.deleteDoc(toDelete));
}
Expand Down

0 comments on commit d938d0c

Please sign in to comment.