Skip to content

知了 Cicada · 任何会议和直播的实时字幕、同声传译、AI 会议纪要,Mac、Windows、Linux、Android 免费开源。Live subtitles, interpreting and meeting notes for any call or stream, on Mac, Windows, Linux and Android.

fix(windows): when an update can't install itself, the tray and settings only say the download page opened if it did

wquguru436d9175a9f9
diff --git a/windows/src/Cicada/App.cs b/windows/src/Cicada/App.cs
index 53ab44e..bfba98d 100644
--- a/windows/src/Cicada/App.cs
+++ b/windows/src/Cicada/App.cs
@@ -80,6 +80,8 @@ sealed class Controller
/// The installer's download progress (0…1) while an update is being fetched, and why the last one failed.
public double? UpdateProgress { get; private set; }
public string? UpdateFailure { get; private set; }
+ /// Whether the browser took the download over after the in-app one failed (it may not open).
+ public bool UpdatePageOpened { get; private set; }
Action? balloonClicked;
Hotkey? hotkey;
TrayFlyout? flyout;
@@ -951,8 +953,8 @@ sealed class Controller
public async void InstallUpdate()
{
if (Updates.Available is not { } u || UpdateProgress is not null) return;
- if (u.Setup is null) { DownloadUpdate(); return; }
- UpdateProgress = 0; UpdateFailure = null;
+ if (u.Setup is null) { _ = DownloadUpdate(); return; }
+ UpdateProgress = 0; UpdateFailure = null; UpdatePageOpened = false;
UpdatesChanged();
try
{
@@ -967,25 +969,26 @@ sealed class Controller
UpdateProgress = null;
UpdateFailure = e is UpdateChecker.Failure f ? L(f.Key) : L("更新包无效");
Log.Debug($"update: in-app install failed ({e.GetType().Name}), opening the download");
+ UpdatePageOpened = DownloadUpdate();
UpdatesChanged();
- DownloadUpdate();
}
}
/// 下载: the browser fetches this PC's installer or zip (or opens the release page when there is none).
- public void DownloadUpdate()
+ public bool DownloadUpdate()
{
- if (Updates.Available is not { } u) return;
- Open(u.Download ?? u.Page);
+ if (Updates.Available is not { } u) return false;
Log.Debug($"update: download {u.Version}");
+ return Open(u.Download ?? u.Page);
}
public void OpenReleaseNotes() { if (Updates.Available is { } u) Open(u.Page); }
- public static void Open(string url)
+ /// False when no browser took it (none set, or Windows refused).
+ public static bool Open(string url)
{
- try { System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(url) { UseShellExecute = true }); }
- catch (Exception e) { Log.Debug($"update: open failed {e.GetType().Name}"); }
+ try { System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(url) { UseShellExecute = true }); return true; }
+ catch (Exception e) { Log.Debug($"update: open failed {e.GetType().Name}: {e.Message}"); return false; }
}
/// 检查更新: says 正在检查… / 已是最新版本 / 连不上 GitHub for a few seconds.
diff --git a/windows/src/Cicada/SettingsWindow.cs b/windows/src/Cicada/SettingsWindow.cs
index 8d7e3d0..e5da518 100644
--- a/windows/src/Cicada/SettingsWindow.cs
+++ b/windows/src/Cicada/SettingsWindow.cs
@@ -111,7 +111,7 @@ sealed class SettingsWindow : Window
{
if (app.Updates.Available is { } u)
return app.UpdateProgress is { } p ? LF("正在下载 %@:%lld%%", u.Version, (long)(p * 100))
- : app.UpdateFailure is { } f ? LF("没能自动更新:%@", f)
+ : app.UpdateFailure is { } f ? (app.UpdatePageOpened ? LF("没能自动更新:%@。已打开下载页", f) : LF("没能自动更新:%@", f))
: LF("有新版本 %@", u.Version) + " · " + UpdateHint(u);
if (app.UpdateCheck is { } c) return c;
if (app.Updates.LastChecked is not { } d) return null;
diff --git a/windows/src/Cicada/TrayFlyout.cs b/windows/src/Cicada/TrayFlyout.cs
index e9f44d9..e90c29b 100644
--- a/windows/src/Cicada/TrayFlyout.cs
+++ b/windows/src/Cicada/TrayFlyout.cs
@@ -82,7 +82,7 @@ sealed class TrayFlyout : Window
{
var size = update.Size > 0 ? $"{update.Size / 1_048_576.0:0} MB · " : "";
var detail = app.UpdateProgress is { } p0 ? LF("正在下载 %@:%lld%%", update.Version, (long)(p0 * 100))
- : app.UpdateFailure is { } f ? LF("没能自动更新:%@。已打开下载页", f)
+ : app.UpdateFailure is { } f ? (app.UpdatePageOpened ? LF("没能自动更新:%@。已打开下载页", f) : LF("没能自动更新:%@", f))
: size + SettingsWindow.UpdateHint(update);
var text = Ui.Stack(2, Ui.Text(LF("新版本 %@", update.Version), 13, Palette.Ink, Palette.Strong, wrap: false),
Ui.Text(detail, 11, Palette.Secondary),