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.
C# audio-converteravaloniabatch-conversionconvertercsharpdocument-converterdocx-to-pdfdotnetdrag-and-dropfile-conversionfile-converterheic-converterhwphwpximage-converterlinuxmacospdf-convertervideo-converterwindows
Update notices say how much an update matters and what it changes
KnifeLemond18dd29ed853
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 26a401ad..5919b075 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -6,10 +6,40 @@ version it publishes under "What's Changed" in the GitHub release notes, above tAdd a `## <version>` section before tagging a release. Write what someone using Filee notices: what's new, where tofind it, what it does and doesn't do.+Start the section with an `<!-- update -->` block (hidden on GitHub). The app's update notice shows its level and its+one-line summaries in the user's language (`ko`, `en`, `zh`; a line per change, a language may repeat):++- `required`: wrong or lost results, security, Filee not starting. The card shows every time Filee starts.+- `recommended`: bug fixes. The card shows once per version.+- `optional`: new features only. No card, the sidebar button only.+## 1.10.3+<!-- update+level: recommended+ko: 엑셀에서 정한 페이지 나누기가 PDF에 반영돼요+ko: 중국어·일본어 등 여러 언어 문서를 PDF로 바꿀 때 그 언어의 글꼴을 써요+ko: 한글 문서의 보기 상자와 수식이 PDF에서 제대로 나와요+ko: Word·엑셀 → PDF를 LibreOffice로 변환하도록 고를 수 있어요+ko: 업데이트 알림에 중요도와 바뀐 내용이 나와요+en: Excel page breaks carry over to PDF+en: Chinese, Japanese and other languages get a font of their own in PDFs+en: Boxes and equations of 한글 documents come out right in PDFs+en: Word and Excel → PDF can go through LibreOffice+en: Update notices say how much an update matters and what it changes+zh: Excel 中设置的分页符会保留到 PDF 中+zh: 中文、日文等文档转为 PDF 时使用对应语言的字体+zh: 韩文 Hangul 文档中的框和公式在 PDF 中正确显示+zh: 可以选择用 LibreOffice 将 Word、Excel 转为 PDF+zh: 更新通知会显示重要程度和更新内容+-->+### New+- **Update notices say how much an update matters.** The card names the update required, recommended or optional and+ lists what it changes in one line each, in the app's language (for someone a few versions behind, every version in+ between). Optional updates no longer bring up the card, only the sidebar button; required ones show it every time+ Filee starts.- **LibreOffice for Word and Excel → PDF** (issue #66). Settings → Engines → "When LibreOffice is installed" has twonew switches, off by default: "Word documents → PDF" (DOCX, DOC, ODT, RTF, laid out as in Word, with Chinese andJapanese punctuation rules) and "Spreadsheets → PDF" (XLSX, XLS, ODS, CSV, with the workbook's print area and pagediff --git a/src/Filee.App/App.axaml.cs b/src/Filee.App/App.axaml.csindex 07e39e26..9ad8ebec 100644--- a/src/Filee.App/App.axaml.cs+++ b/src/Filee.App/App.axaml.cs@@ -127,9 +127,12 @@ public partial class App : Applicationprivate static void WatchForUpdates(UserDataStore store){var updates = AppHost.Get<UpdateService>();+ // Required: the card every time Filee starts (UpdateFound fires once per run). Recommended: once per version.+ // Optional: no card, the sidebar button only. Frequent releases no longer ask every day.updates.UpdateFound += (_, version) =>{- if (store.Settings.NotifiedUpdateVersion == version)+ if (updates.Level == UpdateLevel.Optional+ || updates.Level == UpdateLevel.Recommended && store.Settings.NotifiedUpdateVersion == version)return;store.Settings.NotifiedUpdateVersion = version;store.SaveSettings();diff --git a/src/Filee.App/Assets/i18n/en.json b/src/Filee.App/Assets/i18n/en.jsonindex d7dada74..88d45d67 100644--- a/src/Filee.App/Assets/i18n/en.json+++ b/src/Filee.App/Assets/i18n/en.json@@ -170,6 +170,15 @@"update.failed": "Couldn't update automatically. Download the new version from filee.sh.","update.failed_alert": "Couldn't download the update. Press OK to open filee.sh and download the new version there.","update.cancelled": "Update cancelled. Press Update again to install it.",+ "update.level.Required": "Required update",+ "update.level.Recommended": "Recommended update",+ "update.level.Optional": "Optional update",+ "update.level_hint.Required": "Fixes problems that affect your files. Please update.",+ "update.level_hint.Recommended": "Fixes bugs.",+ "update.level_hint.Optional": "New features. Update whenever you like.",+ "update.pill.Required": "Required",+ "update.pill.Optional": "Optional",+ "update.more_changes": "… and {0} more","general.data_folder": "Settings folder","general.open_data_folder": "Open","general.library": "Presets and toolbars",diff --git a/src/Filee.App/Assets/i18n/ko.json b/src/Filee.App/Assets/i18n/ko.jsonindex 7b3445ea..706176bf 100644--- a/src/Filee.App/Assets/i18n/ko.json+++ b/src/Filee.App/Assets/i18n/ko.json@@ -170,6 +170,15 @@"update.failed": "자동 업데이트가 안 됐어요. filee.sh에서 새 버전을 받아 주세요.","update.failed_alert": "업데이트를 받지 못했어요. 확인을 누르면 filee.sh를 열어 드릴게요. 거기서 새 버전을 받을 수 있어요.","update.cancelled": "업데이트를 취소했어요. 다시 누르면 설치해요.",+ "update.level.Required": "필수 업데이트",+ "update.level.Recommended": "권장 업데이트",+ "update.level.Optional": "선택 업데이트",+ "update.level_hint.Required": "변환 결과에 영향을 주는 문제를 고쳐요. 꼭 업데이트하세요.",+ "update.level_hint.Recommended": "버그를 고쳤어요.",+ "update.level_hint.Optional": "새 기능이에요. 필요할 때 업데이트하면 돼요.",+ "update.pill.Required": "필수",+ "update.pill.Optional": "선택",+ "update.more_changes": "… 외 {0}개","general.data_folder": "설정 폴더","general.open_data_folder": "열기","general.library": "프리셋과 툴바",diff --git a/src/Filee.App/Assets/i18n/zh-CN.json b/src/Filee.App/Assets/i18n/zh-CN.jsonindex 0ce05c26..7958d029 100644--- a/src/Filee.App/Assets/i18n/zh-CN.json+++ b/src/Filee.App/Assets/i18n/zh-CN.json@@ -170,6 +170,15 @@"update.failed": "无法自动更新,请从 filee.sh 下载新版本。","update.failed_alert": "无法下载更新。点击“确定”后会打开 filee.sh,可以在那里下载新版本。","update.cancelled": "已取消更新,再次点击“更新”即可安装。",+ "update.level.Required": "必要更新",+ "update.level.Recommended": "建议更新",+ "update.level.Optional": "可选更新",+ "update.level_hint.Required": "修复了影响转换结果的问题,请务必更新。",+ "update.level_hint.Recommended": "修复了一些问题。",+ "update.level_hint.Optional": "新增功能,需要时再更新即可。",+ "update.pill.Required": "必要",+ "update.pill.Optional": "可选",+ "update.more_changes": "… 另外 {0} 项","general.data_folder": "设置文件夹","general.open_data_folder": "打开","general.library": "预设与工具栏",diff --git a/src/Filee.App/Services/ReleaseNotes.cs b/src/Filee.App/Services/ReleaseNotes.csnew file mode 100644index 00000000..edeb0c43--- /dev/null+++ b/src/Filee.App/Services/ReleaseNotes.cs@@ -0,0 +1,96 @@+// How much an update matters and what it changes, in the user's language. Each version's CHANGELOG section (and so its+// GitHub release notes) starts with a hidden block GitHub does not show:+//+// <!-- update+// level: recommended+// ko: 엑셀 페이지 나누기가 PDF에 반영돼요+// en: Excel page breaks carry over to PDF+// zh: Excel 分页符会保留到 PDF 中+// -->+//+// level is required (wrong results, lost data, security, Filee not starting), recommended (bug fixes) or optional (new+// features). A language line may repeat for more than one change. A release without the block counts as recommended.++namespace Filee.App.Services;++/// <summary>How much an update matters: what the app does about it.</summary>+public enum UpdateLevel+{+ /// <summary>New features: the sidebar button only, no card.</summary>+ Optional,++ /// <summary>Bug fixes: a card once per version.</summary>+ Recommended,++ /// <summary>Wrong results, lost data, security: a highlighted card every time Filee starts.</summary>+ Required,+}++/// <summary>One version's level and one-line summaries by language ("ko", "en", "zh-CN").</summary>+public sealed record ReleaseNote(string Version, UpdateLevel Level, IReadOnlyDictionary<string, IReadOnlyList<string>> Summary)+{+ /// <summary>The summaries in <paramref name="language"/>, else in English, else none.</summary>+ public IReadOnlyList<string> In(string language) =>+ Summary.TryGetValue(language, out var lines) ? lines+ : Summary.TryGetValue("en", out var english) ? english+ : [];+}++public static class ReleaseNotes+{+ private const string Start = "<!-- update";++ /// <summary>The note of <paramref name="version"/> from its release text; recommended and empty without a block.</summary>+ public static ReleaseNote Parse(string version, string? body)+ {+ var level = UpdateLevel.Recommended;+ var summary = new Dictionary<string, List<string>>(StringComparer.Ordinal);+ var start = body?.IndexOf(Start, StringComparison.Ordinal) ?? -1;+ var end = start < 0 ? -1 : body!.IndexOf("-->", start, StringComparison.Ordinal);+ if (end > start)+ {+ foreach (var raw in body![(start + Start.Length)..end].Split('\n'))+ {+ var colon = raw.IndexOf(':');+ if (colon <= 0)+ continue;+ var key = raw[..colon].Trim().ToLowerInvariant();+ var value = raw[(colon + 1)..].Trim();+ if (value.Length == 0)+ continue;+ if (key == "level")+ level = value.ToLowerInvariant() switch+ {+ "required" => UpdateLevel.Required,+ "optional" => UpdateLevel.Optional,+ _ => UpdateLevel.Recommended,+ };+ else if (key is "ko" or "en" or "zh" or "zh-cn")+ {+ var language = key.StartsWith("zh", StringComparison.Ordinal) ? "zh-CN" : key;+ if (!summary.TryGetValue(language, out var lines))+ summary[language] = lines = [];+ lines.Add(value);+ }+ }+ }+ return new ReleaseNote(version, level, summary.ToDictionary(p => p.Key, p => (IReadOnlyList<string>)p.Value));+ }++ /// <summary>The notes of the releases newer than <paramref name="current"/> up to <paramref name="latest"/>, newest first.</summary>+ public static IReadOnlyList<ReleaseNote> Between(IEnumerable<(string Tag, string? Body)> releases, string current, string latest)+ {+ UpdateService.TryParse(latest, out var newest);+ return releases+ .Where(r => UpdateService.IsNewer(r.Tag, current) && UpdateService.TryParse(r.Tag, out var v) && v <= newest)+ .Select(r => (Version: UpdateService.TryParse(r.Tag, out var v) ? v : new Version(), r.Tag, r.Body))+ .GroupBy(r => r.Version)+ .OrderByDescending(g => g.Key)+ .Select(g => Parse(g.Key.ToString(3), g.First().Body))+ .ToList();+ }++ /// <summary>The level of the whole update: the highest of the versions it brings (recommended when none is known).</summary>+ public static UpdateLevel Highest(IReadOnlyList<ReleaseNote> notes) =>+ notes.Count == 0 ? UpdateLevel.Recommended : notes.Max(n => n.Level);+}diff --git a/src/Filee.App/Services/UpdateService.cs b/src/Filee.App/Services/UpdateService.csindex 049bf3f7..8e22c3c5 100644--- a/src/Filee.App/Services/UpdateService.cs+++ b/src/Filee.App/Services/UpdateService.cs@@ -100,6 +100,17 @@ public sealed partial class UpdateService : ObservableObjectpublic bool IsUpdateAvailable => LatestVersion is not null;+ /// <summary>What the versions between this one and <see cref="LatestVersion"/> change, newest first.</summary>+ [ObservableProperty]+ [NotifyPropertyChangedFor(nameof(Level), nameof(IsRequired), nameof(IsOptional))]+ private IReadOnlyList<ReleaseNote> _notes = [];++ /// <summary>How much the update matters: the highest level of the versions it brings.</summary>+ public UpdateLevel Level => ReleaseNotes.Highest(Notes);++ public bool IsRequired => Level == UpdateLevel.Required;+ public bool IsOptional => Level == UpdateLevel.Optional;+/// <summary>Progress of an in-app update.</summary>[ObservableProperty][NotifyPropertyChangedFor(nameof(IsBusy))]@@ -150,7 +161,18 @@ public sealed partial class UpdateService : ObservableObjectvar tag = json.RootElement.TryGetProperty("tag_name", out var value) ? value.GetString() : null;var newer = IsNewer(tag, CurrentVersion) ? Normalize(tag!) : null;(_installer, _checksums) = FindFiles(json.RootElement);- await Dispatcher.UIThread.InvokeAsync(() => Publish(newer, announce));+ IReadOnlyList<ReleaseNote> notes = [];+ if (newer is not null)+ {+ var body = json.RootElement.TryGetProperty("body", out var text) ? text.GetString() : null;+ notes = await NotesAsync(api[..^"/latest".Length], newer, cancellationToken)+ ?? ReleaseNotes.Between([(tag!, body)], CurrentVersion, newer);+ }+ await Dispatcher.UIThread.InvokeAsync(() =>+ {+ Notes = notes; // before Publish: UpdateFound decides by the level+ Publish(newer, announce);+ });return true;}// Offline, DNS failure, timeout, a connection dropped while reading, or an unexpected answer: Filee works@@ -163,6 +185,37 @@ public sealed partial class UpdateService : ObservableObject}}+ /// <summary>+ /// The notes of every release from this version up to <paramref name="latest"/> (someone a few versions behind sees+ /// all of them), or null when the list doesn't come.+ /// </summary>+ private async Task<IReadOnlyList<ReleaseNote>?> NotesAsync(string releasesApi, string latest, CancellationToken cancellationToken)+ {+ try+ {+ using var response = await _http.GetAsync(releasesApi + "?per_page=30", cancellationToken);+ if (!response.IsSuccessStatusCode)+ return null;+ await using var stream = await response.Content.ReadAsStreamAsync(cancellationToken);+ using var json = await JsonDocument.ParseAsync(stream, cancellationToken: cancellationToken);+ if (json.RootElement.ValueKind != JsonValueKind.Array)+ return null;+ var releases = json.RootElement.EnumerateArray()+ .Where(r => !(r.TryGetProperty("draft", out var d) && d.ValueKind == JsonValueKind.True)+ && !(r.TryGetProperty("prerelease", out var p) && p.ValueKind == JsonValueKind.True))+ .Select(r => (Tag: r.TryGetProperty("tag_name", out var t) ? t.GetString() ?? "" : "",+ Body: r.TryGetProperty("body", out var b) ? b.GetString() : null))+ .ToList();+ return ReleaseNotes.Between(releases, CurrentVersion, latest);+ }+ catch (Exception ex) when (ex is HttpRequestException or TaskCanceledException or IOException or JsonException+ or InvalidOperationException)+ {+ _log.LogInformation("Release notes: {Message}", ex.Message);+ return null;+ }+ }+/// <summary>Checks shortly after start and then every few hours while <paramref name="enabled"/> says so.</summary>public void StartPeriodicChecks(Func<bool> enabled, TimeSpan firstDelay){diff --git a/src/Filee.App/Services/UpdateTexts.cs b/src/Filee.App/Services/UpdateTexts.csindex 954e244d..ac23802e 100644--- a/src/Filee.App/Services/UpdateTexts.cs+++ b/src/Filee.App/Services/UpdateTexts.cs@@ -30,7 +30,21 @@ public static class UpdateTexts_ => null,};+ /// <summary>+ /// What the update changes in the app's language, one "• " line per change, newest version first (at most+ /// <paramref name="max"/> lines); empty when the releases say nothing.+ /// </summary>+ public static string Changes(UpdateService updates, ILocalizer loc, int max = 6)+ {+ var lines = updates.Notes.SelectMany(n => n.In(loc.Language)).Distinct().ToList();+ var shown = lines.Take(max).Select(l => "• " + l).ToList();+ if (lines.Count > max)+ shown.Add(loc.Format("update.more_changes", lines.Count - max));+ return string.Join(Environment.NewLine, shown);+ }+/// <summary>True for property changes that alter the texts above.</summary>public static bool Affects(string? propertyName) =>- propertyName is nameof(UpdateService.LatestVersion) or nameof(UpdateService.Step) or nameof(UpdateService.DownloadPercent);+ propertyName is nameof(UpdateService.LatestVersion) or nameof(UpdateService.Step) or nameof(UpdateService.DownloadPercent)+ or nameof(UpdateService.Notes);}diff --git a/src/Filee.App/ViewModels/MainWindowViewModel.cs b/src/Filee.App/ViewModels/MainWindowViewModel.csindex d042ec50..94339b20 100644--- a/src/Filee.App/ViewModels/MainWindowViewModel.cs+++ b/src/Filee.App/ViewModels/MainWindowViewModel.cs@@ -100,7 +100,9 @@ public sealed partial class MainWindowViewModel : ObservableObject{VersionText = _loc.Format("about.version", UpdateService.CurrentVersion);UpdateText = UpdateTexts.Short(Updates, _loc);- UpdateTip = UpdateTexts.Status(Updates, _loc) ?? _loc[UpdateTexts.HowKey];+ var changes = UpdateTexts.Changes(Updates, _loc);+ UpdateTip = UpdateTexts.Status(Updates, _loc)+ ?? $"{_loc[$"update.level.{Updates.Level}"]}{Environment.NewLine}{(changes.Length > 0 ? changes + Environment.NewLine : "")}{_loc[UpdateTexts.HowKey]}";}public void Navigate(string key)diff --git a/src/Filee.App/Views/MainWindow.axaml b/src/Filee.App/Views/MainWindow.axamlindex 66f5d9d1..aaeb24a0 100644--- a/src/Filee.App/Views/MainWindow.axaml+++ b/src/Filee.App/Views/MainWindow.axaml@@ -21,13 +21,25 @@</StackPanel><!-- Bottom: the running version, and a download button when a newer release is out. --><StackPanel DockPanel.Dock="Bottom" Spacing="8" Margin="4,12,4,0">- <Button x:Name="UpdateButton" Classes="accent" HorizontalAlignment="Stretch" HorizontalContentAlignment="Left"+ <!-- Accent for required and recommended updates, plain for optional ones; a pill says which -->+ <Button x:Name="UpdateButton" Classes.accent="{Binding !Updates.IsOptional}" HorizontalAlignment="Stretch"+ HorizontalContentAlignment="Stretch"Command="{Binding DownloadUpdateCommand}" IsVisible="{Binding Updates.IsUpdateAvailable}"ToolTip.Tip="{Binding UpdateTip}">- <StackPanel Orientation="Horizontal" Spacing="8">- <PathIcon Width="14" Height="14" Data="{StaticResource Icon.Download}" />- <TextBlock Text="{Binding UpdateText}" TextTrimming="CharacterEllipsis" />- </StackPanel>+ <DockPanel>+ <Border DockPanel.Dock="Right" CornerRadius="999" Padding="6,1" Margin="6,0,0,0" VerticalAlignment="Center"+ Background="{DynamicResource DangerBrush}" IsVisible="{Binding Updates.IsRequired}">+ <TextBlock Text="{DynamicResource update.pill.Required}" FontSize="11" FontWeight="SemiBold" Foreground="White" />+ </Border>+ <Border DockPanel.Dock="Right" CornerRadius="999" Padding="6,1" Margin="6,0,0,0" VerticalAlignment="Center"+ Background="{DynamicResource SurfaceAltBrush}" IsVisible="{Binding Updates.IsOptional}">+ <TextBlock Classes="caption" Text="{DynamicResource update.pill.Optional}" FontSize="11" />+ </Border>+ <StackPanel Orientation="Horizontal" Spacing="8">+ <PathIcon Width="14" Height="14" Data="{StaticResource Icon.Download}" />+ <TextBlock Text="{Binding UpdateText}" TextTrimming="CharacterEllipsis" />+ </StackPanel>+ </DockPanel></Button><!-- The project on GitHub, and sponsoring it --><Grid ColumnDefinitions="*,6,*">diff --git a/src/Filee.App/Views/UpdateNoticeWindow.axaml b/src/Filee.App/Views/UpdateNoticeWindow.axamlindex 8fc8f121..26c4d522 100644--- a/src/Filee.App/Views/UpdateNoticeWindow.axaml+++ b/src/Filee.App/Views/UpdateNoticeWindow.axaml@@ -1,4 +1,5 @@-<!-- "A new version is out" card in the bottom-right corner, shown once per new version (UpdateService.UpdateFound). -->+<!-- "A new version is out" card in the bottom-right corner (UpdateService.UpdateFound): how much it matters and what+ it changes. Required updates show it every start, recommended ones once per version, optional ones never. --><Window xmlns="https://github.com/avaloniaui"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"x:Class="Filee.App.Views.UpdateNoticeWindow"@@ -23,6 +24,13 @@</Button><TextBlock x:Name="TitleText" FontWeight="SemiBold" TextWrapping="Wrap" VerticalAlignment="Center" /></DockPanel>+ <DockPanel>+ <Border x:Name="LevelPill" DockPanel.Dock="Left" CornerRadius="999" Padding="8,2" Margin="0,0,8,0" VerticalAlignment="Top">+ <TextBlock x:Name="LevelText" FontSize="11.5" FontWeight="SemiBold" />+ </Border>+ <TextBlock x:Name="LevelHint" Classes="caption" TextWrapping="Wrap" VerticalAlignment="Center" />+ </DockPanel>+ <TextBlock x:Name="ChangesText" TextWrapping="Wrap" FontSize="12.5" LineHeight="19" /><TextBlock x:Name="CaptionText" Classes="caption" TextWrapping="Wrap" /><ProgressBar x:Name="Progress" Minimum="0" Maximum="100" IsVisible="False" /><StackPanel x:Name="Buttons" Orientation="Horizontal" Spacing="8" Margin="0,2,0,0">diff --git a/src/Filee.App/Views/UpdateNoticeWindow.axaml.cs b/src/Filee.App/Views/UpdateNoticeWindow.axaml.csindex 904ef1c4..9a7a7af1 100644--- a/src/Filee.App/Views/UpdateNoticeWindow.axaml.cs+++ b/src/Filee.App/Views/UpdateNoticeWindow.axaml.cs@@ -62,11 +62,28 @@ public partial class UpdateNoticeWindow : Windowif (_updates is null || _loc is null)return;CaptionText.Text = UpdateTexts.Status(_updates, _loc) ?? _loc[UpdateTexts.HowKey];+ var level = _updates.Level;+ LevelText.Text = _loc[$"update.level.{level}"];+ LevelHint.Text = _loc[$"update.level_hint.{level}"];+ var (fill, text) = level switch+ {+ UpdateLevel.Required => ("DangerBrush", "OnAccentBrush"),+ UpdateLevel.Recommended => ("AccentSoftBrush", "AccentStrongBrush"),+ _ => ("SurfaceAltBrush", "TextSecondaryBrush"),+ };+ LevelPill.Background = Brush(fill);+ LevelText.Foreground = level == UpdateLevel.Required ? Avalonia.Media.Brushes.White : Brush(text);+ ChangesText.Text = UpdateTexts.Changes(_updates, _loc);+ ChangesText.IsVisible = ChangesText.Text.Length > 0;Progress.IsVisible = _updates.Step == UpdateStep.Downloading;Progress.Value = _updates.DownloadPercent;Buttons.IsVisible = !_updates.IsBusy;}+ /// <summary>A brush of the current light or dark theme (DangerBrush and the text colours depend on it).</summary>+ private Avalonia.Media.IBrush? Brush(string key) =>+ this.TryFindResource(key, ActualThemeVariant, out var value) ? value as Avalonia.Media.IBrush : null;+private void PlaceBottomRight(){var screen = Screens.Primary;diff --git a/tests/Filee.App.Tests/ReleaseNotesTests.cs b/tests/Filee.App.Tests/ReleaseNotesTests.csnew file mode 100644index 00000000..8c202834--- /dev/null+++ b/tests/Filee.App.Tests/ReleaseNotesTests.cs@@ -0,0 +1,112 @@+// The update notice says how much an update matters and what it changes, from a hidden block in the release notes.++using System.Net;+using System.Text;+using System.Text.Json;+using Avalonia.Headless.XUnit;+using Filee.App.Services;+using Microsoft.Extensions.Logging.Abstractions;++namespace Filee.App.Tests;++public class ReleaseNotesTests+{+ private const string Body = """+ ## What's Changed++ <!-- update+ level: required+ ko: 엑셀 페이지 나누기가 PDF에 반영돼요+ ko: 한글 수식이 제대로 나와요+ en: Excel page breaks carry over to PDF+ zh: Excel 分页符会保留到 PDF 中+ -->++ ### Fixed+ """;++ [Fact]+ public void The_hidden_block_gives_the_level_and_a_line_per_change_by_language()+ {+ var note = ReleaseNotes.Parse("1.10.3", Body);++ Assert.Equal(UpdateLevel.Required, note.Level);+ Assert.Equal(["엑셀 페이지 나누기가 PDF에 반영돼요", "한글 수식이 제대로 나와요"], note.In("ko"));+ Assert.Equal(["Excel 分页符会保留到 PDF 中"], note.In("zh-CN"));+ Assert.Equal(["Excel page breaks carry over to PDF"], note.In("ja")); // no Japanese: English+ }++ [Fact]+ public void Releases_without_the_block_are_recommended_and_say_nothing()+ {+ var note = ReleaseNotes.Parse("1.9.0", "### New\n\n- Something");++ Assert.Equal(UpdateLevel.Recommended, note.Level);+ Assert.Empty(note.In("ko"));+ }++ [Fact]+ public void Someone_a_few_versions_behind_gets_every_version_and_the_highest_level()+ {+ var notes = ReleaseNotes.Between(+ [+ ("v9.9.12", "<!-- update\nlevel: optional\n-->"), // newer than the latest the check found: not yet+ ("v9.9.11", "<!-- update\nlevel: optional\nko: 새 기능\n-->"),+ ("v9.9.10", "<!-- update\nlevel: required\nko: 중요한 수정\n-->"),+ ("v9.9.9", "no block"),+ ("v1.0.0", "<!-- update\nlevel: required\n-->"), // older than this version+ ], current: "9.9.9", latest: "9.9.11");++ Assert.Equal(["9.9.11", "9.9.10"], notes.Select(n => n.Version));+ Assert.Equal(UpdateLevel.Required, ReleaseNotes.Highest(notes));+ Assert.Equal(UpdateLevel.Optional, ReleaseNotes.Highest([notes[0]]));+ Assert.Equal(UpdateLevel.Recommended, ReleaseNotes.Highest([]));+ }++ [AvaloniaFact] // the check publishes its answer on the UI thread+ public async Task The_check_reads_the_notes_of_every_newer_release()+ {+ var updates = new UpdateService(NullLogger<UpdateService>.Instance, new Releases());++ Assert.True(await updates.RefreshAsync(announce: false));++ Assert.Equal("9.9.11", updates.LatestVersion);+ Assert.Equal(["9.9.11", "9.9.10"], updates.Notes.Select(n => n.Version));+ Assert.True(updates.IsRequired);+ Assert.Contains("• 중요한 수정", UpdateTexts.Changes(updates, new KoreanOnly()));+ }++ private sealed class KoreanOnly : Filee.Core.Localization.ILocalizer+ {+ public string Language => "ko";+ public string this[string key] => key;+ public string Format(string key, params object[] args) => key;+ public event EventHandler? LanguageChanged { add { } remove { } }+ }++ /// <summary>GitHub with 9.9.11 as the latest release, 9.9.10 required, a draft and an older release.</summary>+ private sealed class Releases : HttpMessageHandler+ {+ private static object Release(string tag, string body, bool draft = false) =>+ new { tag_name = tag, body, draft, prerelease = false, assets = Array.Empty<object>() };++ protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)+ {+ var path = request.RequestUri!.AbsolutePath;+ object? answer = path.EndsWith("/releases/latest", StringComparison.Ordinal)+ ? Release("v9.9.11", "<!-- update\nlevel: optional\nko: 새 기능\n-->")+ : path.EndsWith("/releases", StringComparison.Ordinal)+ ? new[]+ {+ Release("v9.9.12", "<!-- update\nlevel: optional\n-->", draft: true),+ Release("v9.9.11", "<!-- update\nlevel: optional\nko: 새 기능\n-->"),+ Release("v9.9.10", "<!-- update\nlevel: required\nko: 중요한 수정\n-->"),+ Release("v1.0.0", "old"),+ }+ : null;+ return Task.FromResult(answer is null+ ? new HttpResponseMessage(HttpStatusCode.NotFound)+ : new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(JsonSerializer.Serialize(answer), Encoding.UTF8, "application/json") });+ }+ }+}diff --git a/tests/Filee.App.Tests/RenderTests.cs b/tests/Filee.App.Tests/RenderTests.csindex 1e0fa24b..7168c429 100644--- a/tests/Filee.App.Tests/RenderTests.cs+++ b/tests/Filee.App.Tests/RenderTests.cs@@ -450,6 +450,17 @@ public class RenderTeststry{+ updates.Notes = [ReleaseNotes.Parse("9.9.9", """+ <!-- update+ level: recommended+ ko: 엑셀에서 정한 페이지 나누기가 PDF에 반영돼요+ ko: 한글 문서의 보기 상자와 수식이 PDF에서 제대로 나와요+ en: Excel page breaks carry over to PDF+ en: Boxes and equations of 한글 documents come out right in PDFs+ zh: Excel 中设置的分页符会保留到 PDF 中+ zh: 韩文 Hangul 文档中的框和公式在 PDF 中正确显示+ -->+ """)];updates.LatestVersion = "9.9.9";Pump();Assert.True(button.IsVisible);@@ -462,6 +473,22 @@ public class RenderTestsPump();Save(notice, $"update-notice-{language}.png");+ // A required update: red pill on the card and in the sidebar; an optional one: plain button, grey pill.+ updates.Notes = [ReleaseNotes.Parse("9.9.9", """+ <!-- update+ level: required+ ko: 변환 결과가 잘못 나오던 문제를 고쳤어요+ en: Fixes wrong conversion results+ zh: 修复了转换结果错误的问题+ -->+ """)];+ Pump();+ Save(notice, $"update-notice-required-{language}.png");+ Save(window, $"sidebar-update-required-{language}.png");+ updates.Notes = [ReleaseNotes.Parse("9.9.9", "<!-- update\nlevel: optional\nko: 새 기능\nen: A new feature\n-->")];+ Pump();+ Save(window, $"sidebar-update-optional-{language}.png");+// While the installer downloads, the card, the sidebar button and the tray show the progress.updates.Step = UpdateStep.Downloading;updates.DownloadPercent = 42;@@ -482,6 +509,7 @@ public class RenderTests{updates.Step = UpdateStep.Idle;updates.LatestVersion = null;+ updates.Notes = [];window.Close();}}