Skip to content

Commit

Permalink
Disable notifications when System Tray is disabled (fix #2403)
Browse files Browse the repository at this point in the history
  • Loading branch information
marticliment committed Jul 28, 2024
1 parent 0635575 commit 41f8d4a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
7 changes: 6 additions & 1 deletion src/UniGetUI.Core.Settings/SettingsEngine.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
using UniGetUI.Core.Data;
using UniGetUI.Core.Data;
using UniGetUI.Core.Logging;

namespace UniGetUI.Core.SettingsEngine
{
public static class Settings
{
public static bool AreNotificationsDisabled()
{
return Get("DisableSystemTray") || Get("DisableNotifications");
}

public static bool Get(string setting, bool invert = false)
{
return File.Exists(Path.Join(CoreData.UniGetUIDataDirectory, setting)) ^ invert;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ protected override void WhenPackagesLoaded(ReloadReason reason)
ShowButtons = true;
}

if (!(Settings.Get("DisableUpdatesNotifications") || Settings.Get("DisableNotifications")))
if (!(Settings.Get("DisableUpdatesNotifications") || Settings.AreNotificationsDisabled()))
{
try
{
Expand Down
12 changes: 6 additions & 6 deletions src/UniGetUI/PackageEngine/Operations/PackageOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ protected override async Task<AfterFinshAction> HandleFailure()

Package.SetTag(PackageTag.Failed);

if (!Settings.Get("DisableErrorNotifications") && !Settings.Get("DisableNotifications"))
if (!(Settings.Get("DisableErrorNotifications") || Settings.AreNotificationsDisabled()))
{
try
{
Expand Down Expand Up @@ -160,7 +160,7 @@ protected override async Task<AfterFinshAction> HandleSuccess()
Package.SetTag(PackageTag.AlreadyInstalled);
PEInterface.InstalledPackagesLoader.AddForeign(Package);

if (!Settings.Get("DisableSuccessNotifications") && !Settings.Get("DisableNotifications"))
if (!Settings.Get("DisableSuccessNotifications") && !Settings.AreNotificationsDisabled())
{
try
{
Expand Down Expand Up @@ -238,7 +238,7 @@ protected override async Task<AfterFinshAction> HandleFailure()

Package.SetTag(PackageTag.Failed);

if (!Settings.Get("DisableErrorNotifications") && !Settings.Get("DisableNotifications"))
if (!Settings.Get("DisableErrorNotifications") && !Settings.AreNotificationsDisabled())
{
try
{
Expand Down Expand Up @@ -284,7 +284,7 @@ protected override async Task<AfterFinshAction> HandleSuccess()

PEInterface.UpgradablePackagesLoader.Remove(Package);

if (!Settings.Get("DisableSuccessNotifications") && !Settings.Get("DisableNotifications"))
if (!Settings.Get("DisableSuccessNotifications") && !Settings.AreNotificationsDisabled())
{
try
{
Expand Down Expand Up @@ -366,7 +366,7 @@ protected override async Task<AfterFinshAction> HandleFailure()

Package.SetTag(PackageTag.Failed);

if (!Settings.Get("DisableErrorNotifications") && !Settings.Get("DisableNotifications"))
if (!Settings.Get("DisableErrorNotifications") && !Settings.AreNotificationsDisabled())
{
try
{
Expand Down Expand Up @@ -406,7 +406,7 @@ protected override async Task<AfterFinshAction> HandleSuccess()
PEInterface.UpgradablePackagesLoader.Remove(Package);
PEInterface.InstalledPackagesLoader.Remove(Package);

if (!Settings.Get("DisableSuccessNotifications") && !Settings.Get("DisableNotifications"))
if (!Settings.Get("DisableSuccessNotifications") && !Settings.AreNotificationsDisabled())
{
try
{
Expand Down
8 changes: 4 additions & 4 deletions src/UniGetUI/PackageEngine/Operations/SourceOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ protected override OperationVeredict GetProcessVeredict(int ReturnCode, string[]
protected override async Task<AfterFinshAction> HandleFailure()
{
LineInfoText = CoreTools.Translate("Could not add source {source} to {manager}", new Dictionary<string, object?> { { "source", Source.Name }, { "manager", Source.Manager.Name } });
if (!Settings.Get("DisableErrorNotifications") && !Settings.Get("DisableNotifications"))
if (!Settings.Get("DisableErrorNotifications") && !Settings.AreNotificationsDisabled())
{
try
{
Expand Down Expand Up @@ -102,7 +102,7 @@ protected override async Task<AfterFinshAction> HandleSuccess()
{
OperationSucceeded?.Invoke(this, EventArgs.Empty);
LineInfoText = CoreTools.Translate("The source {source} was added to {manager} successfully", new Dictionary<string, object?> { { "source", Source.Name }, { "manager", Source.Manager.Name } });
if (!Settings.Get("DisableSuccessNotifications") && !Settings.Get("DisableNotifications"))
if (!Settings.Get("DisableSuccessNotifications") && !Settings.AreNotificationsDisabled())
{
try
{
Expand Down Expand Up @@ -177,7 +177,7 @@ protected override OperationVeredict GetProcessVeredict(int ReturnCode, string[]
protected override async Task<AfterFinshAction> HandleFailure()
{
LineInfoText = CoreTools.Translate("Could not remove source {source} from {manager}", new Dictionary<string, object?> { { "source", Source.Name }, { "manager", Source.Manager.Name } });
if (!Settings.Get("DisableErrorNotifications") && !Settings.Get("DisableNotifications"))
if (!Settings.Get("DisableErrorNotifications") && !Settings.AreNotificationsDisabled())
{
new ToastContentBuilder()
.AddArgument("action", "OpenUniGetUI")
Expand All @@ -204,7 +204,7 @@ protected override async Task<AfterFinshAction> HandleSuccess()
{
OperationSucceeded?.Invoke(this, EventArgs.Empty);
LineInfoText = CoreTools.Translate("The source {source} was removed from {manager} successfully", new Dictionary<string, object?> { { "source", Source.Name }, { "manager", Source.Manager.Name } });
if (!Settings.Get("DisableSuccessNotifications") && !Settings.Get("DisableNotifications"))
if (!Settings.Get("DisableSuccessNotifications") && !Settings.AreNotificationsDisabled())
{
try
{
Expand Down

0 comments on commit 41f8d4a

Please sign in to comment.