Skip to content

Commit bbe22ed

Browse files
myieyeclaude
andcommitted
Translate IsMain in SubmitUpdatePublication after rebasing onto develop
develop's #2367 rerouted PublicationSync through the new no-re-read SubmitUpdatePublication (so sync tolerates a publication deleted on the other side). That override applied the raw patch, so once the IsMain feature rebased on top, the sync path set IsMain as a plain LWW field and skipped the converging SetMainPublicationChange. Move the IsMain translation into SubmitUpdatePublication so every update path converges; UpdatePublication now just submits and re-reads, matching the SubmitUpdate*/Update* pattern develop uses for the other entity types. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 077d517 commit bbe22ed

1 file changed

Lines changed: 9 additions & 11 deletions

File tree

backend/FwLite/LcmCrdt/CrdtMiniLcmApi.cs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -187,30 +187,28 @@ public async Task<Publication> CreatePublication(Publication pub)
187187

188188
public async Task SubmitUpdatePublication(Guid id, UpdateObjectInput<Publication> update)
189189
{
190-
await AddChanges(update.Patch.ToChanges(id));
191-
}
192-
193-
public async Task<Publication> UpdatePublication(Guid id, UpdateObjectInput<Publication> update)
194-
{
195-
await using var repo = await repoFactory.CreateRepoAsync();
196-
var pub = await repo.GetPublication(id) ?? throw NotFoundException.ForType<Publication>(id);
197-
198190
// IsMain is applied via SetMainPublicationChange (which converges), not as a plain field patch, so it's
199191
// stripped from the patch and translated to that change — but only when an IsMain op is actually present.
200192
if (update.TryGetPropertyChange<Publication, bool>(nameof(Publication.IsMain), out var isMain))
201193
{
202194
var patch = new JsonPatchDocument<Publication>();
203195
patch.Operations.AddRange(update.Patch.Operations.Where(op =>
204196
!string.Equals(op.Path, $"/{nameof(Publication.IsMain)}", StringComparison.OrdinalIgnoreCase)));
205-
var changes = patch.ToChanges(pub.Id).ToList();
197+
var changes = patch.ToChanges(id).ToList();
206198
// prior/wrapping validation actually prevents setting IsMain to false via patch, so isMain is always true
207-
if (isMain) changes.Add(new SetMainPublicationChange(pub.Id));
199+
if (isMain) changes.Add(new SetMainPublicationChange(id));
208200
if (changes.Count > 0) await AddChanges(changes);
209201
}
210202
else if (update.Patch.Operations.Count > 0)
211203
{
212-
await AddChanges(update.Patch.ToChanges(pub.Id));
204+
await AddChanges(update.Patch.ToChanges(id));
213205
}
206+
}
207+
208+
public async Task<Publication> UpdatePublication(Guid id, UpdateObjectInput<Publication> update)
209+
{
210+
await SubmitUpdatePublication(id, update);
211+
await using var repo = await repoFactory.CreateRepoAsync();
214212
return await repo.GetPublication(id) ?? throw NotFoundException.ForType<Publication>($"{id} (invalid patching to a new id?)");
215213
}
216214

0 commit comments

Comments
 (0)