Skip to content

Commit

Permalink
[MergeDups] Restore removal of redundant audio (#2890)
Browse files Browse the repository at this point in the history
  • Loading branch information
imnasnainaec authored Jan 19, 2024
1 parent 5123aab commit ef75bcd
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions Backend/Services/MergeService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,27 @@ private async Task<Word> MergePrepParent(string projectId, MergeWords mergeWords
parent.ProjectId = projectId;
parent.History = new List<string>();

// Add child to history.
foreach (var childSource in mergeWords.Children)
{
// Add child to history.
parent.History.Add(childSource.SrcWordId);

if (childSource.GetAudio)
{
var child = await _wordRepo.GetWord(projectId, childSource.SrcWordId);
if (child is null)
// Add child's audio.
var child = await _wordRepo.GetWord(projectId, childSource.SrcWordId)
?? throw new KeyNotFoundException($"Unable to locate word: ${childSource.SrcWordId}");
child.Audio.ForEach(pro =>
{
throw new KeyNotFoundException($"Unable to locate word: ${childSource.SrcWordId}");
}
parent.Audio.AddRange(child.Audio);
if (parent.Audio.All(p => p.FileName != pro.FileName))
{
parent.Audio.Add(pro);
}
});
}
}

// Remove duplicates.
// Remove history duplicates.
parent.History = parent.History.Distinct().ToList();
return parent;
}
Expand Down

0 comments on commit ef75bcd

Please sign in to comment.