mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-03-31 17:43:04 -06:00
Add DISCORDCHATEXPORTER_SETTINGS_PATH env var support to SettingsService
Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
This commit is contained in:
parent
982b26a806
commit
68af1500c7
|
|
@ -12,11 +12,7 @@ using DiscordChatExporter.Gui.Models;
|
||||||
namespace DiscordChatExporter.Gui.Services;
|
namespace DiscordChatExporter.Gui.Services;
|
||||||
|
|
||||||
[ObservableObject]
|
[ObservableObject]
|
||||||
public partial class SettingsService()
|
public partial class SettingsService() : SettingsBase(GetFilePath(), SerializerContext.Default)
|
||||||
: SettingsBase(
|
|
||||||
Path.Combine(AppContext.BaseDirectory, "Settings.dat"),
|
|
||||||
SerializerContext.Default
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
public partial bool IsUkraineSupportMessageEnabled { get; set; } = true;
|
public partial bool IsUkraineSupportMessageEnabled { get; set; } = true;
|
||||||
|
|
@ -90,6 +86,17 @@ public partial class SettingsService()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public partial class SettingsService
|
||||||
|
{
|
||||||
|
private static string GetFilePath() =>
|
||||||
|
Environment.GetEnvironmentVariable("DISCORDCHATEXPORTER_SETTINGS_PATH") is { } path
|
||||||
|
&& !string.IsNullOrWhiteSpace(path)
|
||||||
|
? Path.EndsInDirectorySeparator(path) || Directory.Exists(path)
|
||||||
|
? Path.Combine(path, "Settings.dat")
|
||||||
|
: path
|
||||||
|
: Path.Combine(AppContext.BaseDirectory, "Settings.dat");
|
||||||
|
}
|
||||||
|
|
||||||
public partial class SettingsService
|
public partial class SettingsService
|
||||||
{
|
{
|
||||||
[JsonSerializable(typeof(SettingsService))]
|
[JsonSerializable(typeof(SettingsService))]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue