mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 10:46:30 +00:00
fixed bugs with queue handling. At least most of them
This commit is contained in:
@@ -1,19 +1,17 @@
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Threading;
|
||||
using System.Windows.Input;
|
||||
using Azaion.Common.Database;
|
||||
using Azaion.Common.DTO;
|
||||
using Azaion.Common.DTO.Queue;
|
||||
using Azaion.Common.Events;
|
||||
using Azaion.Common.Services;
|
||||
using Azaion.CommonSecurity.DTO;
|
||||
using Azaion.CommonSecurity.Services;
|
||||
using MediatR;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Azaion.Dataset;
|
||||
|
||||
public class DatasetExplorerEventHandler(
|
||||
ILogger<DatasetExplorerEventHandler> logger,
|
||||
DatasetExplorer datasetExplorer,
|
||||
IAnnotationService annotationService,
|
||||
IAzaionApi azaionApi) :
|
||||
@@ -22,8 +20,6 @@ public class DatasetExplorerEventHandler(
|
||||
INotificationHandler<AnnotationCreatedEvent>,
|
||||
INotificationHandler<AnnotationsDeletedEvent>
|
||||
{
|
||||
private readonly IAzaionApi _azaionApi = azaionApi;
|
||||
|
||||
private readonly Dictionary<Key, PlaybackControlEnum> _keysControlEnumDict = new()
|
||||
{
|
||||
{ Key.Enter, PlaybackControlEnum.SaveAnnotations },
|
||||
@@ -127,7 +123,7 @@ public class DatasetExplorerEventHandler(
|
||||
if (annotation.Classes.Contains(selectedClass) || selectedClass == -1)
|
||||
{
|
||||
var index = 0;
|
||||
var annThumb = new AnnotationThumbnail(annotation, _azaionApi.CurrentUser.Role.IsValidator());
|
||||
var annThumb = new AnnotationThumbnail(annotation, azaionApi.CurrentUser.Role.IsValidator());
|
||||
if (datasetExplorer.SelectedAnnotationDict.ContainsKey(annThumb.Annotation.Name))
|
||||
{
|
||||
datasetExplorer.SelectedAnnotationDict.Remove(annThumb.Annotation.Name);
|
||||
@@ -148,14 +144,25 @@ public class DatasetExplorerEventHandler(
|
||||
|
||||
public async Task Handle(AnnotationsDeletedEvent notification, CancellationToken cancellationToken)
|
||||
{
|
||||
var annThumbs = datasetExplorer.SelectedAnnotationDict
|
||||
.Where(x => notification.AnnotationNames.Contains(x.Key))
|
||||
.Select(x => x.Value)
|
||||
.ToList();
|
||||
foreach (var annThumb in annThumbs)
|
||||
try
|
||||
{
|
||||
datasetExplorer.SelectedAnnotations.Remove(annThumb);
|
||||
datasetExplorer.SelectedAnnotationDict.Remove(annThumb.Annotation.Name);
|
||||
datasetExplorer.Dispatcher.Invoke(() =>
|
||||
{
|
||||
var annThumbs = datasetExplorer.SelectedAnnotationDict
|
||||
.Where(x => notification.AnnotationNames.Contains(x.Key))
|
||||
.Select(x => x.Value)
|
||||
.ToList();
|
||||
foreach (var annThumb in annThumbs)
|
||||
{
|
||||
datasetExplorer.SelectedAnnotations.Remove(annThumb);
|
||||
datasetExplorer.SelectedAnnotationDict.Remove(annThumb.Annotation.Name);
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.LogError(e, e.Message);
|
||||
throw;
|
||||
}
|
||||
await Task.CompletedTask;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user