mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 13:06:31 +00:00
fixed bugs with queue handling. At least most of them
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Threading;
|
||||
using Azaion.Annotator.DTO;
|
||||
using Azaion.Common;
|
||||
using Azaion.Common.DTO;
|
||||
@@ -276,31 +277,42 @@ public class AnnotatorEventHandler(
|
||||
mainWindow.AddAnnotation(annotation);
|
||||
}
|
||||
|
||||
public async Task Handle(AnnotationsDeletedEvent notification, CancellationToken cancellationToken)
|
||||
public Task Handle(AnnotationsDeletedEvent notification, CancellationToken cancellationToken)
|
||||
{
|
||||
var namesSet = notification.AnnotationNames.ToHashSet();
|
||||
|
||||
var remainAnnotations = formState.AnnotationResults
|
||||
.Where(x => !namesSet.Contains(x.Annotation?.Name ?? "")).ToList();
|
||||
formState.AnnotationResults.Clear();
|
||||
foreach (var ann in remainAnnotations)
|
||||
formState.AnnotationResults.Add(ann);
|
||||
|
||||
var timedAnnsToRemove = mainWindow.TimedAnnotations
|
||||
.Where(x => namesSet.Contains(x.Value.Name))
|
||||
.Select(x => x.Value).ToList();
|
||||
mainWindow.TimedAnnotations.Remove(timedAnnsToRemove);
|
||||
|
||||
if (formState.AnnotationResults.Count == 0)
|
||||
try
|
||||
{
|
||||
var media = mainWindow.AllMediaFiles.FirstOrDefault(x => x.Name == formState.CurrentMedia?.Name);
|
||||
if (media != null)
|
||||
mainWindow.Dispatcher.Invoke(() =>
|
||||
{
|
||||
media.HasAnnotations = false;
|
||||
mainWindow.LvFiles.Items.Refresh();
|
||||
}
|
||||
var namesSet = notification.AnnotationNames.ToHashSet();
|
||||
|
||||
var remainAnnotations = formState.AnnotationResults
|
||||
.Where(x => !namesSet.Contains(x.Annotation?.Name ?? "")).ToList();
|
||||
formState.AnnotationResults.Clear();
|
||||
foreach (var ann in remainAnnotations)
|
||||
formState.AnnotationResults.Add(ann);
|
||||
|
||||
var timedAnnsToRemove = mainWindow.TimedAnnotations
|
||||
.Where(x => namesSet.Contains(x.Value.Name))
|
||||
.Select(x => x.Value).ToList();
|
||||
mainWindow.TimedAnnotations.Remove(timedAnnsToRemove);
|
||||
|
||||
if (formState.AnnotationResults.Count == 0)
|
||||
{
|
||||
var media = mainWindow.AllMediaFiles.FirstOrDefault(x => x.Name == formState.CurrentMedia?.Name);
|
||||
if (media != null)
|
||||
{
|
||||
media.HasAnnotations = false;
|
||||
mainWindow.LvFiles.Items.Refresh();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
await Task.CompletedTask;
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.LogError(e, e.Message);
|
||||
throw;
|
||||
}
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task Handle(AnnotationAddedEvent e, CancellationToken cancellationToken)
|
||||
|
||||
Reference in New Issue
Block a user