Skip to content

Commit

Permalink
feat: Removed the need of restart for the setting (PR not-nullptr#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
iLollek committed Dec 20, 2024
1 parent e440668 commit 5bbbb90
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Aerochat/Windows/Home.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using DSharpPlus.Entities;
using System;
using System.Collections.Concurrent;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.IO;
Expand Down Expand Up @@ -53,6 +54,9 @@ public Home()

// Set visibility of the ad based on settings
UpdateAdVisibility();

// Subscribe to changes in the DisplayAds property
SettingsManager.Instance.PropertyChanged += OnSettingsChange;
});
}

Expand All @@ -61,6 +65,14 @@ private void UpdateAdVisibility()
AdImage.Visibility = SettingsManager.Instance.DisplayAds ? Visibility.Visible : Visibility.Collapsed;
}

private void OnSettingsChange(object? sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == nameof(SettingsManager.Instance.DisplayAds))
{
Dispatcher.Invoke(UpdateAdVisibility);
}
}

public void UpdateUnreadMessages()
{
foreach (var category in ViewModel.Categories)
Expand Down

0 comments on commit 5bbbb90

Please sign in to comment.