Skip to content

Commit

Permalink
Fix local repository Enabled property not getting updated form UI
Browse files Browse the repository at this point in the history
  • Loading branch information
Yoooi0 committed Jun 17, 2024
1 parent c15562b commit 25ebbf4
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,19 @@ namespace MultiFunPlayer.Script.Repository.ViewModels;

[DisplayName("Local")]
[JsonObject(MemberSerialization.OptIn)]
internal sealed class LocalScriptRepository(IEventAggregator eventAggregator) : AbstractScriptRepository, ILocalScriptRepository
internal sealed class LocalScriptRepository : AbstractScriptRepository, ILocalScriptRepository
{
private readonly IEventAggregator _eventAggregator;

private static Logger Logger { get; } = LogManager.GetCurrentClassLogger();

[JsonProperty] public ObservableConcurrentCollection<ScriptLibrary> ScriptLibraries { get; } = [];
[JsonProperty] public new bool Enabled { get; set; } = true;

public LocalScriptRepository(IEventAggregator eventAggregator)
{
_eventAggregator = eventAggregator;
Enabled = true;
}

public override ValueTask<Dictionary<DeviceAxis, IScriptResource>> SearchForScriptsAsync(
MediaResourceInfo mediaResource, IEnumerable<DeviceAxis> axes, ILocalScriptRepository localRepository, CancellationToken token)
Expand Down Expand Up @@ -127,7 +134,7 @@ public void OnLibraryAdd(object sender, RoutedEventArgs e)
var directory = new DirectoryInfo(dialog.FolderName);
ScriptLibraries.Add(new ScriptLibrary(directory));

eventAggregator.Publish(new ReloadScriptsRequestMessage());
_eventAggregator.Publish(new ReloadScriptsRequestMessage());
}

public void OnLibraryDelete(object sender, RoutedEventArgs e)
Expand All @@ -137,7 +144,7 @@ public void OnLibraryDelete(object sender, RoutedEventArgs e)

ScriptLibraries.Remove(library);

eventAggregator.Publish(new ReloadScriptsRequestMessage());
_eventAggregator.Publish(new ReloadScriptsRequestMessage());
}

public void OnLibraryOpenFolder(object sender, RoutedEventArgs e)
Expand Down

0 comments on commit 25ebbf4

Please sign in to comment.