Skip to content

Commit

Permalink
Fixed sonarqube issues
Browse files Browse the repository at this point in the history
  • Loading branch information
hoffe86 committed Dec 17, 2023
1 parent 8230c9d commit 504e54a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/openHAB.Windows/Controls/SetpointWidget.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs
string newValue = (string)e.AddedItems.FirstOrDefault();
if (Widget.Item.Unit != null)
{
newValue = newValue.Replace(Widget.Item.Unit, string.Empty, StringComparison.InvariantCultureIgnoreCase);
newValue = newValue?.Replace(Widget.Item.Unit, string.Empty, StringComparison.InvariantCultureIgnoreCase);
}

if (newValue != null)
Expand Down
7 changes: 4 additions & 3 deletions src/openHAB.Windows/ViewModel/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public class MainViewModel : ViewModelBase<object>
private readonly StoreServicesFeedbackLauncher _feedbackLauncher;
private readonly IOpenHAB _openHabsdk;
private readonly ISettingsService _settingsService;
private CancellationTokenSource _cancellationTokenSource;
private ObservableCollection<OpenHABWidget> _currentWidgets;
private ActionCommand _feedbackCommand;
private bool _isDataLoading;
Expand Down Expand Up @@ -56,7 +55,6 @@ public MainViewModel(IOpenHAB openHabsdk, ISettingsService settingsService, ILog
_openHabsdk = openHabsdk;
_settingsService = settingsService;
_feedbackLauncher = StoreServicesFeedbackLauncher.GetDefault();
_cancellationTokenSource = new CancellationTokenSource();

StrongReferenceMessenger.Default.Register<TriggerCommandMessage>(this, async (recipient, msg) => await TriggerCommand(recipient, msg).ConfigureAwait(false));
StrongReferenceMessenger.Default.Register<WidgetClickedMessage>(this, (recipient, msg) => OnWidgetClickedAction(recipient, msg.Widget));
Expand Down Expand Up @@ -254,7 +252,10 @@ private async void OnWidgetClickedAction(object recipient, OpenHABWidget widget)
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
public async Task LoadSitemapsAndItemData()
{
await LoadData(_cancellationTokenSource.Token).ConfigureAwait(false);
using (CancellationTokenSource cancellationTokenSource = new CancellationTokenSource())
{
await LoadData(cancellationTokenSource.Token).ConfigureAwait(false);
}
}

private async Task ReloadSitemap()
Expand Down

0 comments on commit 504e54a

Please sign in to comment.