Attempt to fix some wonky selection bugs
This commit is contained in:
@@ -45,5 +45,7 @@ public class AggerateLockerItemViewModelHandler(IMediator mediator,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var d = cache;
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,8 @@ public class CreatedItemHandler(IServiceProvider serviceProvider,
|
||||
int index = cache.IndexOf(item);
|
||||
valueStore.Set(item);
|
||||
|
||||
publisher.Publish(Insert.As(index, viewModel), nameof(LockerViewModel));
|
||||
publisher.Publish(Insert.As(index, viewModel),
|
||||
nameof(ItemCollectionViewModel));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Toolkit.Foundation;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
@@ -27,6 +28,11 @@ public partial class ItemCollectionViewModel :
|
||||
|
||||
public IContentTemplate Template { get; set; }
|
||||
|
||||
public override Task OnDeactivated()
|
||||
{
|
||||
return base.OnDeactivated();
|
||||
}
|
||||
|
||||
public Task Handle(NotifyEventArgs<Filter> args)
|
||||
{
|
||||
if (args.Value is Filter filter)
|
||||
|
||||
@@ -14,7 +14,7 @@ public partial class ItemContentViewModel :
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer,
|
||||
IContentTemplate template,
|
||||
bool immutable = true) : base(provider, factory, mediator, publisher, subscriber, disposer)
|
||||
ItemState state = ItemState.Read) : base(provider, factory, mediator, publisher, subscriber, disposer)
|
||||
{
|
||||
Template = template;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ public partial class ItemHeaderViewModel : Observable<string, string>,
|
||||
IItemEntryViewModel
|
||||
{
|
||||
[ObservableProperty]
|
||||
private bool immutable;
|
||||
private ItemState state;
|
||||
|
||||
public ItemHeaderViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
@@ -20,10 +20,10 @@ public partial class ItemHeaderViewModel : Observable<string, string>,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer,
|
||||
bool immutable,
|
||||
ItemState state,
|
||||
string? value = null) : base(provider, factory, mediator, publisher, subscriber, disposer, value)
|
||||
{
|
||||
Immutable = immutable;
|
||||
State = state;
|
||||
Value = value;
|
||||
|
||||
Track(nameof(Value), () => Value, newValue => Value = newValue);
|
||||
@@ -39,21 +39,21 @@ public partial class ItemHeaderViewModel : Observable<string, string>,
|
||||
CancellationToken cancellationToken) => Task.FromResult(new ItemHeaderConfiguration { Name = Value! });
|
||||
|
||||
public Task Handle(UpdateEventArgs<Item> args) =>
|
||||
Task.FromResult(Immutable = false);
|
||||
Task.FromResult(State = ItemState.Write);
|
||||
|
||||
public Task Handle(CancelEventArgs<Item> args)
|
||||
{
|
||||
Revert();
|
||||
Immutable = true;
|
||||
|
||||
State = ItemState.Read;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task Handle(ConfirmEventArgs<Item> args)
|
||||
{
|
||||
Commit();
|
||||
Immutable = true;
|
||||
|
||||
State = ItemState.Read;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace Bitvault;
|
||||
|
||||
public enum ItemState
|
||||
{
|
||||
Read,
|
||||
Write
|
||||
}
|
||||
+29
-19
@@ -17,7 +17,7 @@ public partial class ItemViewModel :
|
||||
private bool favourite;
|
||||
|
||||
[ObservableProperty]
|
||||
private bool immutable;
|
||||
private ItemState state;
|
||||
|
||||
[ObservableProperty]
|
||||
private string named;
|
||||
@@ -25,6 +25,8 @@ public partial class ItemViewModel :
|
||||
[ObservableProperty]
|
||||
private string name;
|
||||
|
||||
[ObservableProperty]
|
||||
private bool test;
|
||||
public ItemViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
@@ -33,20 +35,22 @@ public partial class ItemViewModel :
|
||||
IDisposer disposer,
|
||||
IContentTemplate template,
|
||||
NamedComponent named,
|
||||
ItemState state = ItemState.Read,
|
||||
bool test = false,
|
||||
string name = "",
|
||||
bool immutable = true,
|
||||
bool favourite = false,
|
||||
bool archived = false) : base(provider, factory, mediator, publisher, subscriber, disposer)
|
||||
{
|
||||
Test = test;
|
||||
Named = $"{named}";
|
||||
Template = template;
|
||||
Immutable = immutable;
|
||||
State = state;
|
||||
Favourite = favourite;
|
||||
Archived = archived;
|
||||
Name = name;
|
||||
|
||||
Add<ItemHeaderViewModel>(immutable, name);
|
||||
Add<ItemContentViewModel>(immutable);
|
||||
Add<ItemHeaderViewModel>(state, name);
|
||||
Add<ItemContentViewModel>(state);
|
||||
}
|
||||
|
||||
public IContentTemplate Template { get; set; }
|
||||
@@ -59,6 +63,7 @@ public partial class ItemViewModel :
|
||||
Factory.Create<DismissItemActionViewModel>(),
|
||||
})));
|
||||
|
||||
State = ItemState.Write;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
@@ -70,6 +75,7 @@ public partial class ItemViewModel :
|
||||
Factory.Create<ArchiveItemActionViewModel>(),
|
||||
})));
|
||||
|
||||
State = ItemState.Read;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
@@ -82,20 +88,13 @@ public partial class ItemViewModel :
|
||||
Factory.Create<ArchiveItemActionViewModel>(),
|
||||
})));
|
||||
|
||||
State = ItemState.Read;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public override Task OnActivated()
|
||||
{
|
||||
if (!Immutable)
|
||||
{
|
||||
Publisher.Publish(Notify.As(Factory.Create<ItemCommandHeaderCollection>(new List<IDisposable>
|
||||
{
|
||||
Factory.Create<ConfirmItemActionViewModel>(),
|
||||
Factory.Create<DismissItemActionViewModel>(),
|
||||
})));
|
||||
}
|
||||
else if (Archived)
|
||||
if (Archived)
|
||||
{
|
||||
Publisher.Publish(Notify.As(Factory.Create<ItemCommandHeaderCollection>(new List<IDisposable>
|
||||
{
|
||||
@@ -104,12 +103,23 @@ public partial class ItemViewModel :
|
||||
}
|
||||
else
|
||||
{
|
||||
Publisher.Publish(Notify.As(Factory.Create<ItemCommandHeaderCollection>(new List<IDisposable>
|
||||
if (State is ItemState.Write)
|
||||
{
|
||||
Factory.Create<FavouriteItemActionViewModel>(Favourite),
|
||||
Factory.Create<EditItemActionViewModel>(),
|
||||
Factory.Create<ArchiveItemActionViewModel>(),
|
||||
})));
|
||||
Publisher.Publish(Notify.As(Factory.Create<ItemCommandHeaderCollection>(new List<IDisposable>
|
||||
{
|
||||
Factory.Create<ConfirmItemActionViewModel>(),
|
||||
Factory.Create<DismissItemActionViewModel>(),
|
||||
})));
|
||||
}
|
||||
else
|
||||
{
|
||||
Publisher.Publish(Notify.As(Factory.Create<ItemCommandHeaderCollection>(new List<IDisposable>
|
||||
{
|
||||
Factory.Create<FavouriteItemActionViewModel>(Favourite),
|
||||
Factory.Create<EditItemActionViewModel>(),
|
||||
Factory.Create<ArchiveItemActionViewModel>(),
|
||||
})));
|
||||
}
|
||||
}
|
||||
|
||||
return base.OnActivated();
|
||||
|
||||
@@ -28,7 +28,8 @@ public class ModifiedItemHandler(IServiceProvider serviceProvider,
|
||||
int newIndex = cache.IndexOf(newItem);
|
||||
valueStore.Set(newItem);
|
||||
|
||||
publisher.Publish(MoveTo.As<ItemNavigationViewModel>(oldIndex, newIndex), nameof(LockerViewModel));
|
||||
publisher.Publish(MoveTo.As<ItemNavigationViewModel>(oldIndex, newIndex),
|
||||
nameof(ItemCollectionViewModel));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user