Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
rmunn committed Dec 4, 2024
1 parent 62b7cc8 commit db8aff0
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions backend/FwLite/MiniLcm/SyncHelpers/SenseSync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,24 @@ public static async Task<int> Sync(Guid entryId,
afterSense.ExampleSentences,
beforeSense.ExampleSentences,
api);
changes += await DiffCollection.Diff(api,
beforeSense.SemanticDomains,
afterSense.SemanticDomains,
async (api, domain) =>
{
await api.AddSemanticDomainToSense(beforeSense.Id, domain);
return 1;
},
async (api, beforeDomain) =>
{
await api.RemoveSemanticDomainFromSense(beforeSense.Id, beforeDomain.Id);
return 1;
},
(_, beforeDomain, afterDomain) =>
{
//do nothing, semantic domains are not editable here
return Task.FromResult(0);
});
return changes + (updateObjectInput is null ? 0 : 1);
}

Expand All @@ -38,25 +56,6 @@ public static async Task<int> Sync(Guid entryId,
patchDocument.Replace(sense => sense.PartOfSpeechId, afterSense.PartOfSpeechId);
}

await DiffCollection.Diff(null!,
beforeSense.SemanticDomains,
afterSense.SemanticDomains,
(_, domain) =>
{
patchDocument.Add(sense => sense.SemanticDomains, domain);
return Task.FromResult(1);
},
(_, beforeDomain) =>
{
patchDocument.Remove(sense => sense.SemanticDomains,
beforeSense.SemanticDomains.IndexOf(beforeDomain));
return Task.FromResult(1);
},
(_, beforeDomain, afterDomain) =>
{
//do nothing, semantic domains are not editable here
return Task.FromResult(0);
});
if (patchDocument.Operations.Count == 0) return null;
return new UpdateObjectInput<Sense>(patchDocument);
}
Expand Down

0 comments on commit db8aff0

Please sign in to comment.