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

Add missing entry change notifications #1380

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
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
Loading