Skip to content

Commit

Permalink
Added: static method handler for LoadoutItemModel
Browse files Browse the repository at this point in the history
  • Loading branch information
Sewer56 committed Jan 9, 2025
1 parent 16e9ccc commit 2529ba6
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/NexusMods.App.UI/Pages/LoadoutPage/LoadoutItemModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Microsoft.Extensions.DependencyInjection;
using NexusMods.Abstractions.Loadouts;
using NexusMods.Abstractions.NexusModsLibrary;
using NexusMods.Abstractions.UI.Extensions;
using NexusMods.App.UI.Controls;
using NexusMods.MnemonicDB.Abstractions;
using NexusMods.Paths;
Expand Down Expand Up @@ -55,9 +56,11 @@ public LoadoutItemModel(LoadoutItemId loadoutItemId, IServiceProvider servicePro
return ids.Select(id => (Id: id, ShouldEnable: shouldEnable)).ToArray();
});

_modelActivationDisposable = WhenModelActivated(this, (model, disposables) =>
var state = (loadoutItemId, serviceProvider, connection, loadThumbnail);
_modelActivationDisposable = this.WhenActivated(state, static (model, tuple, disposables) =>
{
ShowThumbnail.Value = loadThumbnail;
var (loadoutItemId, serviceProvider, connection, loadThumbnail) = tuple;
model.ShowThumbnail.Value = loadThumbnail;

if (loadThumbnail)
{
Expand All @@ -67,7 +70,7 @@ public LoadoutItemModel(LoadoutItemId loadoutItemId, IServiceProvider servicePro
{
ImagePipelines.CreateObservable(nexusLibraryItem.ModPageMetadataId, modPageThumbnailPipeline)
.ObserveOnUIThreadDispatcher()
.Subscribe(this, static (bitmap, self) => self.Thumbnail.Value = bitmap)
.Subscribe(model, static (bitmap, self) => self.Thumbnail.Value = bitmap)
.AddTo(disposables);
}
}
Expand Down

0 comments on commit 2529ba6

Please sign in to comment.