Skip to content

Commit

Permalink
Warn when using development build (#1248)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyrrrz authored May 31, 2024
1 parent 520c06d commit 4298011
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
6 changes: 5 additions & 1 deletion DiscordChatExporter.Gui/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@ 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/DiscordChatExporter";

public static string DocumentationUrl { get; } = ProjectUrl + "/tree/master/.docs";
public static string ProjectReleasesUrl { get; } = $"{ProjectUrl}/releases";

public static string ProjectDocumentationUrl { get; } = ProjectUrl + "/tree/master/.docs";

public static AppBuilder BuildAvaloniaApp() =>
AppBuilder.Configure<App>().UsePlatformDetect().LogToTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private async Task ShowSettingsAsync() =>
await _dialogManager.ShowDialogAsync(_viewModelManager.CreateSettingsViewModel());

[RelayCommand]
private void ShowHelp() => ProcessEx.StartShellExecute(Program.DocumentationUrl);
private void ShowHelp() => ProcessEx.StartShellExecute(Program.ProjectDocumentationUrl);

private bool CanPullGuilds() => !IsBusy && !string.IsNullOrWhiteSpace(Token);

Expand Down
26 changes: 26 additions & 0 deletions DiscordChatExporter.Gui/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=discordchatexporter");
}

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 4298011

Please sign in to comment.