Skip to content

Commit cb95afe

Browse files
Reduce Windows publish payload (#4981)
1 parent af3deb6 commit cb95afe

5 files changed

Lines changed: 45 additions & 13 deletions

File tree

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using System.Runtime.ExceptionServices;
2+
3+
namespace UniGetUI.Avalonia.Extensions;
4+
5+
internal static class ObservableSubscriptionExtensions
6+
{
7+
public static IDisposable SubscribeValue<T>(this IObservable<T> source, Action<T> onNext)
8+
{
9+
ArgumentNullException.ThrowIfNull(source);
10+
ArgumentNullException.ThrowIfNull(onNext);
11+
12+
return source.Subscribe(new ActionObserver<T>(onNext));
13+
}
14+
15+
private sealed class ActionObserver<T>(Action<T> onNext) : IObserver<T>
16+
{
17+
public void OnCompleted()
18+
{
19+
}
20+
21+
public void OnError(Exception error)
22+
{
23+
ExceptionDispatchInfo.Capture(error).Throw();
24+
}
25+
26+
public void OnNext(T value)
27+
=> onNext(value);
28+
}
29+
}

‎src/UniGetUI.Avalonia/UniGetUI.Avalonia.csproj‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@
153153
<PackageReference Include="Avalonia.Controls.DataGrid" Version="12.0.0" />
154154
<PackageReference Include="Avalonia.Desktop" Version="12.0.4" />
155155
<PackageReference Include="Avalonia.Themes.Fluent" Version="12.0.4" />
156-
<PackageReference Include="Devolutions.AvaloniaTheme.MacOS" Version="2026.3.13" />
157-
<PackageReference Include="Devolutions.AvaloniaTheme.Linux" Version="2026.3.11" />
156+
<PackageReference Include="Devolutions.AvaloniaTheme.MacOS" Version="2026.3.13" Condition="$([MSBuild]::IsOSPlatform('OSX'))" />
157+
<PackageReference Include="Devolutions.AvaloniaTheme.Linux" Version="2026.3.11" Condition="$([MSBuild]::IsOSPlatform('Linux'))" />
158158
<PackageReference Include="AvaloniaUI.DiagnosticsSupport" Version="2.2.0-beta3" Condition="'$(EnableAvaloniaDiagnostics)' == 'true'" />
159159
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.*" />
160160
<PackageReference Include="Octokit" Version="14.0.0" />

‎src/UniGetUI.Avalonia/Views/Controls/Settings/SecureCheckboxCard.cs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using Avalonia.Controls;
44
using Avalonia.Layout;
55
using Avalonia.Media;
6+
using UniGetUI.Avalonia.Extensions;
67
using UniGetUI.Avalonia.Infrastructure;
78
using UniGetUI.Core.Logging;
89
using UniGetUI.Core.SettingsEngine.SecureSettings;
@@ -134,7 +135,7 @@ public SecureCheckboxCard()
134135
_checkbox.IsCheckedChanged += (s, e) => _ = _checkbox_Toggled();
135136

136137
this.GetObservable(IsEnabledProperty)
137-
.Subscribe(enabled => _warningBlock.Opacity = enabled ? 1 : 0.2);
138+
.SubscribeValue(enabled => _warningBlock.Opacity = enabled ? 1 : 0.2);
138139

139140
// The Devolutions SettingsCard measures the Header with infinite width, so
140141
// TextWrapping alone won't constrain the warning block. We fix it by updating

‎src/UniGetUI.Avalonia/Views/MainWindow.axaml.cs‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using Avalonia.Media;
1111
using Avalonia.Threading;
1212
using Avalonia.VisualTree;
13+
using UniGetUI.Avalonia.Extensions;
1314
using UniGetUI.Avalonia.Infrastructure;
1415
using UniGetUI.Avalonia.ViewModels;
1516
using UniGetUI.Avalonia.Views.Pages;
@@ -128,7 +129,7 @@ public MainWindow()
128129

129130
Resized += (_, _) => _ = SaveGeometryAsync();
130131
PositionChanged += (_, _) => _ = SaveGeometryAsync();
131-
this.GetObservable(WindowStateProperty).Subscribe(state => { _ = SaveGeometryAsync(); });
132+
this.GetObservable(WindowStateProperty).SubscribeValue(state => { _ = SaveGeometryAsync(); });
132133

133134
_trayService = new TrayService(this);
134135
_trayService.UpdateStatus();
@@ -290,7 +291,7 @@ private void UpdateOperationsPanelRow()
290291
// windows give the content full width (the hamburger + sliding flyout still provide nav).
291292
private void SetupResponsiveRail()
292293
=> MainContentRoot.GetObservable(BoundsProperty)
293-
.Subscribe(b =>
294+
.SubscribeValue(b =>
294295
{
295296
if (b.Width <= 0) return;
296297
NavRail.IsVisible = b.Width >= 800;
@@ -314,7 +315,7 @@ private void SetupTitleBar()
314315
// collapses to 0, which would clip the search box and hamburger. Use a fixed
315316
// title bar height in that state, and drop the traffic-light reservation
316317
// since the traffic lights aren't shown either.
317-
this.GetObservable(WindowStateProperty).Subscribe(state =>
318+
this.GetObservable(WindowStateProperty).SubscribeValue(state =>
318319
{
319320
if (state == WindowState.FullScreen)
320321
{
@@ -354,7 +355,7 @@ private void SetupTitleBar()
354355
HamburgerPanel.Margin = new Thickness(10, 0, 8, 0);
355356
WindowButtons.IsVisible = true;
356357
MainContentRoot.Margin = new Thickness(0, 44, 0, 0);
357-
this.GetObservable(WindowStateProperty).Subscribe(state =>
358+
this.GetObservable(WindowStateProperty).SubscribeValue(state =>
358359
{
359360
UpdateMaximizeButtonState(state == WindowState.Maximized);
360361
});
@@ -372,7 +373,7 @@ private void SetupTitleBar()
372373
WindowButtons.IsVisible = !useNativeDecorations;
373374
MainContentRoot.Margin = new Thickness(0, 44, 0, 0);
374375
// Keep maximize icon in sync with window state
375-
this.GetObservable(WindowStateProperty).Subscribe(state =>
376+
this.GetObservable(WindowStateProperty).SubscribeValue(state =>
376377
{
377378
UpdateMaximizeButtonState(state == WindowState.Maximized);
378379
});

‎src/UniGetUI.Avalonia/Views/SoftwarePages/AbstractPackagesPage.axaml.cs‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using Avalonia.Media;
1212
using Avalonia.Media.Transformation;
1313
using Avalonia.Threading;
14+
using UniGetUI.Avalonia.Extensions;
1415
using UniGetUI.Avalonia.ViewModels.Pages;
1516
using UniGetUI.Avalonia.Views.Controls;
1617
using UniGetUI.Core.SettingsEngine;
@@ -95,7 +96,7 @@ or nameof(PackagesPageViewModel.SortAscending))
9596
// Using ColumnDefinition.WidthProperty fires every drag step, not just on release.
9697
FilteringPanel.ColumnDefinitions[0]
9798
.GetObservable(ColumnDefinition.WidthProperty)
98-
.Subscribe(width =>
99+
.SubscribeValue(width =>
99100
{
100101
if (_isOverlayMode || !ViewModel.IsFilterPaneOpen) return;
101102
if (width.IsAbsolute && width.Value >= 100)
@@ -114,19 +115,19 @@ or nameof(PackagesPageViewModel.SortAscending))
114115

115116
// Responsive: switch between inline and overlay modes based on content width.
116117
FilteringPanel.GetObservable(BoundsProperty)
117-
.Subscribe(bounds => OnFilteringPanelWidthChanged(bounds.Width));
118+
.SubscribeValue(bounds => OnFilteringPanelWidthChanged(bounds.Width));
118119

119120
// Responsive: collapse the menu bar to icon-only on narrow windows so the
120121
// toolbar buttons stay reachable instead of overflowing (mirrors WinUI).
121122
this.GetObservable(BoundsProperty)
122-
.Subscribe(bounds => ViewModel.SetToolbarLabelsCollapsed(bounds.Width < 900));
123+
.SubscribeValue(bounds => ViewModel.SetToolbarLabelsCollapsed(bounds.Width < 900));
123124

124125
// Grid/icons views: stretch cards to fill each row then reflow (mirrors WinUI's
125126
// UniformGridLayout) instead of leaving wasted space to the right.
126127
GridViewItems.GetObservable(BoundsProperty)
127-
.Subscribe(bounds => UpdateGridCardWidth(bounds.Width));
128+
.SubscribeValue(bounds => UpdateGridCardWidth(bounds.Width));
128129
IconsViewItems.GetObservable(BoundsProperty)
129-
.Subscribe(bounds => UpdateIconCardWidth(bounds.Width));
130+
.SubscribeValue(bounds => UpdateIconCardWidth(bounds.Width));
130131

131132
// Overlay backdrop dismisses the filter pane when tapped.
132133
FilterOverlayBackdrop.PointerPressed += (_, _) => ViewModel.IsFilterPaneOpen = false;

0 commit comments

Comments
 (0)