Skip to content

Commit

Permalink
Warn when running a development build (#452)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyrrrz authored May 31, 2024
1 parent fa958fc commit 8785821
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
6 changes: 6 additions & 0 deletions YoutubeDownloader/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ public static class Program

public static string VersionString { get; } = Version.ToString(3);

public static bool IsDevelopmentBuild { get; } = Version.Major is <= 0 or >= 999;

public static string ProjectUrl { get; } = "https://github.com/Tyrrrz/YoutubeDownloader";

public static string ProjectReleasesUrl { get; } = $"{ProjectUrl}/releases";

public static AppBuilder BuildAvaloniaApp() =>
AppBuilder.Configure<App>().UsePlatformDetect().LogToTrace().UseDesktopWebView();

Expand Down
4 changes: 0 additions & 4 deletions YoutubeDownloader/Services/UpdateService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,6 @@ public void FinalizeUpdate(bool needRestart)
if (!settingsService.IsAutoUpdateEnabled)
return;

// Onova only works on Windows currently
if (!OperatingSystem.IsWindows())
return;

if (_updateVersion is null || !_updatePrepared || _updaterLaunched)
return;

Expand Down
26 changes: 26 additions & 0 deletions YoutubeDownloader/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Diagnostics;
using System.Threading.Tasks;
using Avalonia;
using CommunityToolkit.Mvvm.Input;
Expand Down Expand Up @@ -46,6 +47,30 @@ Click LEARN MORE to find ways that you can help.
ProcessEx.StartShellExecute("https://tyrrrz.me/ukraine?source=youtubedownloader");
}

private async Task ShowDevelopmentBuildMessageAsync()
{
if (!Program.IsDevelopmentBuild)
return;

// If debugging, the user is likely a developer
if (Debugger.IsAttached)
return;

var dialog = viewModelManager.CreateMessageBoxViewModel(
"Unstable build warning",
"""
You're using a development build of the application. These builds are not thoroughly tested and may contain bugs.

Auto-updates are disabled for development builds. If you want to switch to a stable release, please download it manually.
""",
"SEE RELEASES",
"CLOSE"
);

if (await dialogManager.ShowDialogAsync(dialog) == true)
ProcessEx.StartShellExecute(Program.ProjectReleasesUrl);
}

private async Task CheckForUpdatesAsync()
{
try
Expand Down Expand Up @@ -80,6 +105,7 @@ private async Task CheckForUpdatesAsync()
private async Task InitializeAsync()
{
await ShowUkraineSupportMessageAsync();
await ShowDevelopmentBuildMessageAsync();
await CheckForUpdatesAsync();
}

Expand Down

0 comments on commit 8785821

Please sign in to comment.