Skip to content

armgit / Filee

Public Imported from GitHub
0

Free, open-source file converter. Convert 263 formats offline by drag & drop — images, PDF, Word, Excel, PowerPoint, HWP/HWPX, video, audio, e-books and archives. No upload, no Office needed.

fix(update): open progress dialog on update start via StartUpdateAsync and avoid repeating percentage

gtxPrime9744d5dd4488
diff --git a/src/Filee.App/Services/TrayService.cs b/src/Filee.App/Services/TrayService.cs
index cc714b4d..7e5664a2 100644
--- a/src/Filee.App/Services/TrayService.cs
+++ b/src/Filee.App/Services/TrayService.cs
@@ -30,15 +30,7 @@ public sealed class TrayService(UserDataStore store, ILocalizer loc, IPlatformSe
_quit = new NativeMenuItem();
_quit.Click += (_, _) => (app.ApplicationLifetime as IClassicDesktopStyleApplicationLifetime)?.Shutdown();
_update = new NativeMenuItem();
- _update.Click += async (_, _) =>
- {
- if (updates.IsBusy)
- {
- windows.ShowUpdateProgress(updates);
- return;
- }
- await updates.UpdateAsync();
- };
+ _update.Click += async (_, _) => await windows.StartUpdateAsync(updates);
_tray = new TrayIcon
{
diff --git a/src/Filee.App/Services/WindowService.cs b/src/Filee.App/Services/WindowService.cs
index 0950a2a6..bb4688d3 100644
--- a/src/Filee.App/Services/WindowService.cs
+++ b/src/Filee.App/Services/WindowService.cs
@@ -198,6 +198,23 @@ public sealed class WindowService(ILocalizer loc, IServiceProvider services, Mem
notice.Show();
}
+ /// <summary>
+ /// Starts downloading and installing an update, and opens the progress dialog.
+ /// Used by the sidebar, About page, and tray menu (the update notice has its own progress bar).
+ /// </summary>
+ public async Task StartUpdateAsync(UpdateService updates)
+ {
+ if (updates.IsBusy)
+ {
+ ShowUpdateProgress(updates);
+ return;
+ }
+
+ var update = updates.UpdateAsync();
+ ShowUpdateProgress(updates);
+ await update;
+ }
+
/// <summary>Shows the update download progress dialog with a progress bar.</summary>
public void ShowUpdateProgress(UpdateService updates)
{
@@ -361,6 +378,7 @@ public sealed class WindowService(ILocalizer loc, IServiceProvider services, Mem
public async Task ShowUpdateFailedAsync()
{
_updateNotice?.Close();
+ _updateProgress?.Close();
await MessageAsync(_main is { IsVisible: true } main ? main : null, loc["update.failed_alert"]);
services.GetRequiredService<UpdateService>().OpenDownloadPage();
}
diff --git a/src/Filee.App/ViewModels/MainWindowViewModel.cs b/src/Filee.App/ViewModels/MainWindowViewModel.cs
index 24747659..a4229275 100644
--- a/src/Filee.App/ViewModels/MainWindowViewModel.cs
+++ b/src/Filee.App/ViewModels/MainWindowViewModel.cs
@@ -86,15 +86,7 @@ public sealed partial class MainWindowViewModel : ObservableObject, IDisposable
/// <summary>Downloads and runs the new installer (or opens the download page in a portable copy).</summary>
[RelayCommand]
- private async Task DownloadUpdate()
- {
- if (Updates.IsBusy)
- {
- AppHost.Get<WindowService>().ShowUpdateProgress(Updates);
- return;
- }
- await Updates.UpdateAsync();
- }
+ private Task DownloadUpdate() => AppHost.Get<WindowService>().StartUpdateAsync(Updates);
private void OnUpdatesChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
{
diff --git a/src/Filee.App/ViewModels/Pages/AboutPageViewModel.cs b/src/Filee.App/ViewModels/Pages/AboutPageViewModel.cs
index 1e25909c..ea9f3172 100644
--- a/src/Filee.App/ViewModels/Pages/AboutPageViewModel.cs
+++ b/src/Filee.App/ViewModels/Pages/AboutPageViewModel.cs
@@ -70,15 +70,7 @@ public sealed partial class AboutPageViewModel : ObservableObject, IDisposable
/// <summary>Downloads and runs the new installer, which updates Filee in place (a portable copy opens the download page).</summary>
[RelayCommand]
- private async Task DownloadUpdate()
- {
- if (_updates.IsBusy)
- {
- AppHost.Get<WindowService>().ShowUpdateProgress(_updates);
- return;
- }
- await _updates.UpdateAsync();
- }
+ private Task DownloadUpdate() => AppHost.Get<WindowService>().StartUpdateAsync(_updates);
private void ShowUpdateState(string? newer, bool afterCheck = false)
{
diff --git a/src/Filee.App/Views/UpdateProgressWindow.axaml.cs b/src/Filee.App/Views/UpdateProgressWindow.axaml.cs
index 85c75435..647a0206 100644
--- a/src/Filee.App/Views/UpdateProgressWindow.axaml.cs
+++ b/src/Filee.App/Views/UpdateProgressWindow.axaml.cs
@@ -64,7 +64,9 @@ public partial class UpdateProgressWindow : Window
ProgressBar.IsIndeterminate = false;
ProgressBar.Value = _updates.DownloadPercent;
PercentText.Text = $"{_updates.DownloadPercent}%";
- StatusText.Text = _loc.Format("update.downloading", _updates.DownloadPercent);
+ var text = _loc["update.downloading"];
+ var ellipsis = text.IndexOf('…');
+ StatusText.Text = ellipsis >= 0 ? text[..(ellipsis + 1)] : text;
break;
case UpdateStep.Installing:
diff --git a/tests/Filee.App.Tests/UpdateServiceTests.cs b/tests/Filee.App.Tests/UpdateServiceTests.cs
index befb7d4e..a74b1fc5 100644
--- a/tests/Filee.App.Tests/UpdateServiceTests.cs
+++ b/tests/Filee.App.Tests/UpdateServiceTests.cs
@@ -318,7 +318,8 @@ public class UpdateServiceTests
Assert.Equal(45, window.ProgressBar.Value);
Assert.Equal("45%", window.PercentText.Text);
- Assert.Contains("45%", window.StatusText.Text);
+ Assert.DoesNotContain("45%", window.StatusText.Text);
+ Assert.StartsWith(loc["update.downloading"].Split('…')[0], window.StatusText.Text);
updates.DownloadPercent = 90;
Assert.Equal(90, window.ProgressBar.Value);