Skip to content

Commit

Permalink
Updates dependencies and some cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
Leayal committed Dec 20, 2024
1 parent e279000 commit dee84b6
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ namespace Leayal.SnowBreakLauncher
{
static internal class AssemblyInfo
{
public const string Version = "1.3.9";
public const string Version = "1.3.10";
}
}
55 changes: 55 additions & 0 deletions src/Classes/ObservableExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using System;
using System.Collections.Generic;
using System.Threading;

namespace Leayal.SnowBreakLauncher.Classes
{
static class ObservableExtensions
{
sealed class Stub_OnTargetPropChanged<T> : IObserver<T>
{
public readonly Action<T> _onTargetPropChanged;
private T? lastValue;

public Stub_OnTargetPropChanged(Action<T> onTargetPropChanged)
{
this._onTargetPropChanged = onTargetPropChanged;
this.lastValue = default;
}

public void OnCompleted()
{
// Do nothing
}

public void OnError(Exception error)
{
// Do nothing
}

public void OnNext(T value)
{
if (!EqualityComparer<T>.Default.Equals(this.lastValue, value))
{
this.lastValue = value;
this._onTargetPropChanged(value);
}
}
}

public static IDisposable Subscribe<T>(this IObservable<T> observable, Action<T> onTargetPropChanged)
{
var obj = new Stub_OnTargetPropChanged<T>(onTargetPropChanged);
return observable.Subscribe(obj);
}

public static void Subscribe<T>(this IObservable<T> observable, Action<T> onTargetPropChanged, CancellationToken cancellationToken)
{
var canceller = Subscribe(observable, onTargetPropChanged);
if (cancellationToken.CanBeCanceled)
{
cancellationToken.Register(canceller.Dispose);
}
}
}
}
2 changes: 1 addition & 1 deletion src/Controls/CarouselAutoplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Threading;
using Leayal.SnowBreakLauncher.Classes;
using System;
using System.Runtime.CompilerServices;
using System.Threading;
Expand Down Expand Up @@ -40,7 +41,6 @@ public CarouselAutoplay(Carousel carousel)
var observable = this.carousel.GetObservable(Carousel.IsEffectivelyEnabledProperty);
this.observeProp = observable.Subscribe(this.OnTargetPropChanged);
}

private void Carousel_Unloaded(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
{
var topLevel = Interlocked.Exchange(ref this.topLevel, null);
Expand Down
14 changes: 6 additions & 8 deletions src/SnowBreakLauncher.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,15 @@
</PackageReference>
<PackageReference Include="System.IO.Pipelines" Version="8.0.0" />
<PackageReference Condition="!$(DefineConstants.Contains('NO_WMI'))" Include="System.Management" Version="8.0.0" />
<PackageReference Include="Avalonia" Version="11.1.4" />
<PackageReference Include="Avalonia.Desktop" Version="11.1.4" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.1.4" />
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.1.4" />
<PackageReference Include="MessageBox.Avalonia" Version="3.1.6.13" />
<PackageReference Include="Avalonia" Version="11.2.3" />
<PackageReference Include="Avalonia.Desktop" Version="11.2.3" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.2.3" />
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.2.3" />
<PackageReference Include="MessageBox.Avalonia" Version="3.2.0" />
<!--"Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration." is partially wrong-->
<!--As of avalon v11.0.0, for whatever reasons, building with configuration Release without this package will simply fail with XAML Parse error (Unable to resolve type SimpleTheme from namespace https://github.com/avaloniaui)-->
<!--The option to workaround this is not using SimpleTheme, or including this package below to build with SimpleTheme.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.1.4" />
<PackageReference Include="System.Reactive" Version="6.0.1" />
<PackageReference Include="Tmds.DBus.Protocol" Version="0.20.0" />
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.2.3" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit dee84b6

Please sign in to comment.