From 0c366b16731a86f0bf73a4b54a686a59b9e31d91 Mon Sep 17 00:00:00 2001 From: routersys Date: Sun, 11 Oct 2026 20:57:36 +0900 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=80=9A=E7=9F=A5=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SpectrumColorShiftUpdateNotifier.cs | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 SpectrumColorShift/SpectrumColorShiftUpdateNotifier.cs diff --git a/SpectrumColorShift/SpectrumColorShiftUpdateNotifier.cs b/SpectrumColorShift/SpectrumColorShiftUpdateNotifier.cs new file mode 100644 index 0000000..5299f0f --- /dev/null +++ b/SpectrumColorShift/SpectrumColorShiftUpdateNotifier.cs @@ -0,0 +1,52 @@ +using System.Windows; +using GitHubUpdateNotifier; +using YukkuriMovieMaker.Plugin.Update; +using Notifier = GitHubUpdateNotifier.GitHubUpdateNotifier; + +namespace SpectrumColorShift; + +internal static class SpectrumColorShiftUpdateNotifier +{ + private const string Owner = "routersys"; + private const string Repository = "YMM4-SpectrumColorShift"; + private static int _started; + + public static void EnsureCheckedOnce() + { + if (Application.Current is null || Interlocked.Exchange(ref _started, 1) != 0) + return; + _ = RunAsync(); + } + + private static async Task RunAsync() + { + try + { + var options = new UpdateNotifierOptions + { + CurrentVersion = PluginVersion.FromAssemblyInformationalVersion(typeof(SpectrumColorShiftUpdateNotifier)), + IncludePrerelease = false, + MessageFormatter = FormatMessage, + NotificationHandler = ShowNotificationAsync, + }; + await new Notifier(Owner, Repository, options).NotifyAsync().ConfigureAwait(false); + } + catch (Exception exception) + { + if (exception is not UpdateCheckException) + SpectrumColorShiftTelemetry.Report(exception); + } + } + + private static string FormatMessage(UpdateInfo update) + => string.Format(Texts.UpdateAvailableMessage, update.TagName) + Environment.NewLine + update.ReleaseUrl; + + private static Task ShowNotificationAsync(UpdateNotification notification, CancellationToken cancellationToken) + { + var application = Application.Current; + if (application is null) + return Task.CompletedTask; + return application.Dispatcher.InvokeAsync(() => + MessageBox.Show(notification.Message, Texts.SpectrumColorShift, MessageBoxButton.OK, MessageBoxImage.Information)).Task; + } +}