Skip to content

Commit

Permalink
Add missing entry change notifications (#1380)
Browse files Browse the repository at this point in the history
  • Loading branch information
myieye authored Jan 17, 2025
1 parent 8dd28ee commit 0bcaab4
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions backend/FwLite/FwLiteShared/Sync/SyncService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ private async Task SendNotifications(SyncResults syncResults)
await foreach (var entryId in syncResults.MissingFromLocal
.SelectMany(c => c.Snapshots, (commit, snapshot) => snapshot.Entity)
.ToAsyncEnumerable()
.SelectAwait(async e => await GetEntryId(e.DbObject as IObjectWithId))
.SelectMany(e => GetEntryId(e.DbObject as IObjectWithId))
.Distinct())
{
if (entryId is null) continue;
Expand All @@ -74,15 +74,26 @@ private async Task SendNotifications(SyncResults syncResults)
}
}

private async ValueTask<Guid?> GetEntryId(IObjectWithId? entity)
private async IAsyncEnumerable<Guid?> GetEntryId(IObjectWithId? entity)
{
return entity switch
switch (entity)
{
Entry entry => entry.Id,
Sense sense => sense.EntryId,
ExampleSentence exampleSentence => (await dataModel.GetLatest<Sense>(exampleSentence.SenseId))?.EntryId,
_ => null
};
case Entry entry:
yield return entry.Id;
break;
case Sense sense:
yield return sense.EntryId;
break;
case ExampleSentence exampleSentence:
yield return (await dataModel.GetLatest<Sense>(exampleSentence.SenseId))?.EntryId;
break;
case ComplexFormComponent complexFormComponent:
yield return complexFormComponent.ComplexFormEntryId;
yield return complexFormComponent.ComponentEntryId;
break;
default:
break;
}
}

public async Task UploadProject(Guid lexboxProjectId, LexboxServer server)
Expand Down

0 comments on commit 0bcaab4

Please sign in to comment.