Skip to content

Commit 1a99814

Browse files
committed
PR comments
1 parent 232c6d0 commit 1a99814

13 files changed

+62
-52
lines changed

.github/workflows/release.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ jobs:
148148
$newAppCastSignaturePath = $newAppCastPath + ".signature"
149149
& ./scripts/Update-AppCast.ps1 `
150150
-tag "${{ github.ref_name }}" `
151-
-version "${{ steps.version.outputs.VERSION }}" `
152151
-channel stable `
153152
-x64Path "${{ steps.release.outputs.X64_OUTPUT_PATH }}" `
154153
-arm64Path "${{ steps.release.outputs.ARM64_OUTPUT_PATH }}" `

App/Controls/TrayIcon.xaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
<XamlUICommand
3333
Label="Show Window"
3434
Description="Show Window"
35-
Command="{x:Bind OpenCommand, Mode=OneWay}">
35+
Command="{x:Bind OpenCommand}">
3636

3737
<XamlUICommand.IconSource>
3838
<SymbolIconSource Symbol="OpenPane" />
@@ -53,7 +53,7 @@
5353
<XamlUICommand
5454
Label="Check for Updates"
5555
Description="Check for Updates"
56-
Command="{x:Bind CheckForUpdatesCommand, Mode=OneWay}">
56+
Command="{x:Bind CheckForUpdatesCommand}">
5757

5858
<XamlUICommand.IconSource>
5959
<SymbolIconSource Symbol="Download" />
@@ -74,7 +74,7 @@
7474
<XamlUICommand
7575
Label="Exit"
7676
Description="Exit"
77-
Command="{x:Bind ExitCommand, Mode=OneWay}">
77+
Command="{x:Bind ExitCommand}">
7878

7979
<XamlUICommand.IconSource>
8080
<SymbolIconSource Symbol="ClosePane" />

App/Services/SettingsManager.cs

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,43 @@ namespace Coder.Desktop.App.Services;
2828
Task Write(T settings, CancellationToken ct = default);
2929
}
3030

31+
public static class SettingsManagerUtils
32+
{
33+
private const string AppName = "CoderDesktop";
34+
35+
/// <summary>
36+
/// Generates the settings directory path and ensures it exists.
37+
/// </summary>
38+
/// <param name="settingsFilePath">Custom settings root, defaults to AppData/Local</param>
39+
public static string AppSettingsDirectory(string? settingsFilePath = null)
40+
{
41+
if (settingsFilePath is null)
42+
{
43+
settingsFilePath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
44+
}
45+
else if (!Path.IsPathRooted(settingsFilePath))
46+
{
47+
throw new ArgumentException("settingsFilePath must be an absolute path if provided", nameof(settingsFilePath));
48+
}
49+
50+
var folder = Path.Combine(
51+
settingsFilePath,
52+
AppName);
53+
54+
Directory.CreateDirectory(folder);
55+
return folder;
56+
}
57+
}
58+
3159
/// <summary>
32-
/// Implemention of <see cref="ISettingsManager"/> that persists settings to a JSON file
33-
/// located in the user's local application data folder.
60+
/// Implementation of <see cref="ISettingsManager"/> that persists settings to
61+
/// a JSON file located in the user's local application data folder.
3462
/// </summary>
3563
public sealed class SettingsManager<T> : ISettingsManager<T> where T : ISettings<T>, new()
3664
{
65+
3766
private readonly string _settingsFilePath;
38-
private readonly string _appName = "CoderDesktop";
39-
private string _fileName;
67+
private readonly string _fileName;
4068

4169
private T? _cachedSettings;
4270

@@ -49,20 +77,7 @@ namespace Coder.Desktop.App.Services;
4977
/// </param>
5078
public SettingsManager(string? settingsFilePath = null)
5179
{
52-
if (settingsFilePath is null)
53-
{
54-
settingsFilePath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
55-
}
56-
else if (!Path.IsPathRooted(settingsFilePath))
57-
{
58-
throw new ArgumentException("settingsFilePath must be an absolute path if provided", nameof(settingsFilePath));
59-
}
60-
61-
var folder = Path.Combine(
62-
settingsFilePath,
63-
_appName);
64-
65-
Directory.CreateDirectory(folder);
80+
var folder = SettingsManagerUtils.AppSettingsDirectory(settingsFilePath);
6681

6782
_fileName = T.SettingsFileName;
6883
_settingsFilePath = Path.Combine(folder, _fileName);

App/Services/UpdateController.cs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.ComponentModel.DataAnnotations;
4+
using System.IO;
45
using System.Runtime.InteropServices;
56
using System.Threading;
67
using System.Threading.Tasks;
@@ -11,6 +12,8 @@
1112
using Microsoft.UI.Xaml;
1213
using NetSparkleUpdater;
1314
using NetSparkleUpdater.AppCastHandlers;
15+
using NetSparkleUpdater.AssemblyAccessors;
16+
using NetSparkleUpdater.Configurations;
1417
using NetSparkleUpdater.Enums;
1518
using NetSparkleUpdater.Interfaces;
1619
using NetSparkleUpdater.SignatureVerifiers;
@@ -94,10 +97,16 @@ public SparkleUpdateController(ILogger<SparkleUpdateController> logger, IOptions
9497
publicKey: _config.PublicKeyBase64,
9598
readFileBeingVerifiedInChunks: true);
9699

100+
// Tell NetSparkle to store its configuration in the same directory as
101+
// our other config files.
102+
var appConfigDir = SettingsManagerUtils.AppSettingsDirectory();
103+
var sparkleConfigPath = Path.Combine(appConfigDir, "updater.json");
104+
var sparkleAssemblyAccessor = new AssemblyDiagnosticsAccessor(null); // null => use current executable path
105+
var sparkleConfig = new JSONConfiguration(sparkleAssemblyAccessor, sparkleConfigPath);
106+
97107
_sparkle = new SparkleUpdater(_config.AppCastUrl, checker)
98108
{
99-
// TODO: custom Configuration for persistence, could just specify
100-
// our own save path with JSONConfiguration TBH
109+
Configuration = sparkleConfig,
101110
// GitHub releases endpoint returns a random UUID as the filename,
102111
// so we tell NetSparkle to ignore it and use the last segment of
103112
// the URL instead.
@@ -141,14 +150,14 @@ public async Task CheckForUpdatesNow()
141150
try
142151
{
143152
if (coderFactory is not null)
144-
coderFactory.ForceDisableToasts = true;
153+
coderFactory.ForceDisableToastMessages = true;
145154

146155
await _sparkle.CheckForUpdatesAtUserRequest(true);
147156
}
148157
finally
149158
{
150159
if (coderFactory is not null)
151-
coderFactory.ForceDisableToasts = false;
160+
coderFactory.ForceDisableToastMessages = false;
152161
}
153162
}
154163

@@ -192,7 +201,7 @@ public override List<AppCastItem> FilterUpdates(List<AppCastItem> items)
192201
// ReSharper disable once InconsistentNaming // the interface name is "UI", not "Ui"
193202
public class CoderSparkleUIFactory(IUserNotifier userNotifier, IUpdaterUpdateAvailableViewModelFactory updateAvailableViewModelFactory) : IUIFactory
194203
{
195-
public bool ForceDisableToasts;
204+
public bool ForceDisableToastMessages;
196205

197206
bool IUIFactory.HideReleaseNotes { get; set; }
198207
bool IUIFactory.HideSkipButton { get; set; }
@@ -276,7 +285,7 @@ void IUIFactory.ShowDownloadErrorMessage(string message, string? appcastUrl)
276285

277286
bool IUIFactory.CanShowToastMessages()
278287
{
279-
return !ForceDisableToasts;
288+
return !ForceDisableToastMessages;
280289
}
281290

282291
void IUIFactory.ShowToast(Action clickHandler)

App/Views/MessageWindow.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
MinWidth="500" MinHeight="240">
1313

1414
<Window.SystemBackdrop>
15-
<DesktopAcrylicBackdrop />
15+
<MicaBackdrop />
1616
</Window.SystemBackdrop>
1717

1818
<Grid Padding="24">

App/Views/MessageWindow.xaml.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
using System.Diagnostics;
2-
using Windows.Foundation;
3-
using Windows.Graphics;
41
using Coder.Desktop.App.Utils;
52
using Microsoft.UI.Xaml;
6-
using Microsoft.UI.Xaml.Media;
73
using WinUIEx;
84

95
namespace Coder.Desktop.App.Views;
@@ -21,7 +17,6 @@ public MessageWindow(string title, string content, string windowTitle = "Coder D
2117

2218
InitializeComponent();
2319
TitleBarIcon.SetTitlebarIcon(this);
24-
SystemBackdrop = new DesktopAcrylicBackdrop();
2520
this.CenterOnScreen();
2621
AppWindow.Show();
2722

App/Views/UpdaterCheckingForUpdatesWindow.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
Width="500" Height="190">
1414

1515
<Window.SystemBackdrop>
16-
<DesktopAcrylicBackdrop />
16+
<MicaBackdrop />
1717
</Window.SystemBackdrop>
1818

1919
<StackPanel Orientation="Vertical" Padding="32">

App/Views/UpdaterCheckingForUpdatesWindow.xaml.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using Microsoft.UI.Xaml.Media;
21
using System;
32
using Coder.Desktop.App.Utils;
43
using NetSparkleUpdater.Interfaces;
@@ -15,7 +14,6 @@ public UpdaterCheckingForUpdatesWindow()
1514
{
1615
InitializeComponent();
1716
TitleBarIcon.SetTitlebarIcon(this);
18-
SystemBackdrop = new DesktopAcrylicBackdrop();
1917
AppWindow.Hide();
2018

2119
Closed += (_, _) => UpdatesUIClosing?.Invoke(this, EventArgs.Empty);

App/Views/UpdaterDownloadProgressWindow.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
MinWidth="500" MinHeight="190">
1414

1515
<Window.SystemBackdrop>
16-
<DesktopAcrylicBackdrop />
16+
<MicaBackdrop />
1717
</Window.SystemBackdrop>
1818

1919
<Frame x:Name="RootFrame" />

App/Views/UpdaterDownloadProgressWindow.xaml.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using Microsoft.UI.Xaml.Media;
21
using Coder.Desktop.App.Utils;
32
using Coder.Desktop.App.ViewModels;
43
using Coder.Desktop.App.Views.Pages;
@@ -16,7 +15,7 @@ public sealed partial class UpdaterDownloadProgressWindow : WindowEx, IDownloadP
1615

1716
public UpdaterDownloadProgressViewModel ViewModel;
1817

19-
private bool _didCallDownloadProcessCompletedHandler;
18+
private bool _downloadProcessCompletedInvoked;
2019

2120
public UpdaterDownloadProgressWindow(UpdaterDownloadProgressViewModel viewModel)
2221
{
@@ -25,7 +24,6 @@ public UpdaterDownloadProgressWindow(UpdaterDownloadProgressViewModel viewModel)
2524

2625
InitializeComponent();
2726
TitleBarIcon.SetTitlebarIcon(this);
28-
SystemBackdrop = new DesktopAcrylicBackdrop();
2927
AppWindow.Hide();
3028

3129
RootFrame.Content = new UpdaterDownloadProgressMainPage(ViewModel);
@@ -35,9 +33,9 @@ public UpdaterDownloadProgressWindow(UpdaterDownloadProgressViewModel viewModel)
3533

3634
public void SendResponse(DownloadInstallEventArgs args)
3735
{
38-
if (_didCallDownloadProcessCompletedHandler)
36+
if (_downloadProcessCompletedInvoked)
3937
return;
40-
_didCallDownloadProcessCompletedHandler = true;
38+
_downloadProcessCompletedInvoked = true;
4139
DownloadProcessCompleted?.Invoke(this, args);
4240
}
4341

App/Views/UpdaterUpdateAvailableWindow.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
MinWidth="600" MinHeight="500">
1515

1616
<Window.SystemBackdrop>
17-
<DesktopAcrylicBackdrop />
17+
<MicaBackdrop />
1818
</Window.SystemBackdrop>
1919

2020
<Frame x:Name="RootFrame" />

App/Views/UpdaterUpdateAvailableWindow.xaml.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using Microsoft.UI.Xaml.Media;
21
using Coder.Desktop.App.Utils;
32
using Coder.Desktop.App.ViewModels;
43
using Coder.Desktop.App.Views.Pages;
@@ -32,7 +31,6 @@ public UpdaterUpdateAvailableWindow(UpdaterUpdateAvailableViewModel viewModel)
3231

3332
InitializeComponent();
3433
TitleBarIcon.SetTitlebarIcon(this);
35-
SystemBackdrop = new DesktopAcrylicBackdrop();
3634
AppWindow.Hide();
3735

3836
RootFrame.Content = new UpdaterUpdateAvailableMainPage(ViewModel);
@@ -53,7 +51,8 @@ void IUpdateAvailable.Show()
5351

5452
void IUpdateAvailable.Close()
5553
{
56-
UserRespondedToUpdateCheck(UpdateAvailableResult.None); // the Avalonia UI does this "just in case"
54+
// The NetSparkle built-in Avalonia UI does this "just in case"
55+
UserRespondedToUpdateCheck(UpdateAvailableResult.None);
5756
Close();
5857
}
5958

scripts/Update-AppCast.ps1

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#
66
# Usage: Update-AppCast.ps1
77
# -tag <tag>
8-
# -version <version>
98
# -channel <stable|preview>
109
# -x64Path <path>
1110
# -arm64Path <path>
@@ -18,10 +17,6 @@ param (
1817
[ValidatePattern("^v\d+\.\d+\.\d+$")]
1918
[string] $tag,
2019

21-
[Parameter(Mandatory = $true)]
22-
[ValidatePattern("^\d+\.\d+\.\d+$")]
23-
[string] $version,
24-
2520
[Parameter(Mandatory = $true)]
2621
[ValidateSet('stable', 'preview')]
2722
[string] $channel,
@@ -57,6 +52,8 @@ $ErrorActionPreference = "Stop"
5752

5853
$repo = "coder/coder-desktop-windows"
5954

55+
$version = $tag.Substring(1) # remove the v prefix
56+
6057
function Get-Ed25519Signature {
6158
param (
6259
[Parameter(Mandatory = $true)]

0 commit comments

Comments
 (0)