Skip to content

Commit

Permalink
The most significant changes involve modifications to the `StrongRefe…
Browse files Browse the repository at this point in the history
…renceMessenger.Default.Send` and `StrongReferenceMessenger.Default.Register` method calls in `MainWindow.xaml.cs`, `MainViewModel.cs`, and `SitemapViewModel.cs`. These methods now include additional arguments related to the sitemap name. Additionally, the `StrongReferenceMessenger.Default.Unregister` method call was removed from `MainViewModel.cs`. Lastly, several build properties were removed from `openHAB.Windows.GeneratedMSBuildEditorConfig.editorconfig`, indicating potential changes in the project configuration or build process.

List of changes:

1. The namespaces `System` and `System.Threading.Tasks` were removed and then added back in `MainWindow.xaml.cs` and `SitemapViewModel.cs`. This could be due to reordering of the namespaces.
2. The `StrongReferenceMessenger.Default.Send` method calls in `MainWindow.xaml.cs` were modified to include `Vm.SelectedSitemap.Name` as an additional argument.
3. The `StrongReferenceMessenger.Default.Register` method calls in `MainViewModel.cs` and `SitemapViewModel.cs` were modified to include the sitemap name as an additional argument.
4. The `StrongReferenceMessenger.Default.Unregister` method call in `MainViewModel.cs` was removed.
5. The `StrongReferenceMessenger.Default.Send` method calls in `SitemapViewModel.cs` were modified to include `Model.Name` as an additional argument.
6. Several build properties were removed from `openHAB.Windows.GeneratedMSBuildEditorConfig.editorconfig`. This could be due to changes in the project configuration or build process.
  • Loading branch information
hoffe86 committed Mar 23, 2024
1 parent 98e717d commit f0630f2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 25 deletions.
8 changes: 4 additions & 4 deletions src/openHAB.Windows/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System;
using System.Threading.Tasks;
using CommunityToolkit.Mvvm.Messaging;
using CommunityToolkit.WinUI;
using Microsoft.Extensions.Logging;
Expand All @@ -15,6 +13,8 @@
using openHAB.Windows.Services;
using openHAB.Windows.View;
using openHAB.Windows.ViewModel;
using System;
using System.Threading.Tasks;
using Windows.ApplicationModel;

namespace openHAB.Windows
Expand Down Expand Up @@ -74,7 +74,7 @@ private void BreadcrumbBar_ItemClicked(BreadcrumbBar sender, BreadcrumbBarItemCl
return;
}

StrongReferenceMessenger.Default.Send(new WidgetNavigationMessage(null, widget, EventTriggerSource.Breadcrumb));
StrongReferenceMessenger.Default.Send(new WidgetNavigationMessage(null, widget, EventTriggerSource.Breadcrumb), Vm.SelectedSitemap.Name);
}

private async Task ShowErrorMessage(object recipient, ConnectionErrorMessage message)
Expand Down Expand Up @@ -159,7 +159,7 @@ private void SitemapNavigation_SelectionChanged(

private void SitemapTextBlock_Tapped(object sender, Microsoft.UI.Xaml.Input.TappedRoutedEventArgs e)
{
StrongReferenceMessenger.Default.Send(new WidgetNavigationMessage(null, null, EventTriggerSource.Root));
StrongReferenceMessenger.Default.Send(new WidgetNavigationMessage(null, null, EventTriggerSource.Root), Vm.SelectedSitemap.Name);
}
}
}
7 changes: 2 additions & 5 deletions src/openHAB.Windows/ViewModel/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ public MainViewModel(IOpenHABClient openHABClient, ISettingsService settingsServ

StrongReferenceMessenger.Default.Register<DataOperation>(this, async (obj, operation)
=> await DataOperationStateAsync(operation));

StrongReferenceMessenger.Default.Register<WidgetNavigationMessage>(this, (obj, operation)
=> WidgetNavigatedEvent());
}

/// <summary>
Expand Down Expand Up @@ -116,7 +113,6 @@ public Sitemap SelectedSitemap
{
if (_selectedSitemap != value)
{

StrongReferenceMessenger.Default.Unregister<WidgetNavigationMessage, string>(this, value.Name);
}

Expand All @@ -128,7 +124,8 @@ public Sitemap SelectedSitemap
settings.LastSitemap = _selectedSitemap.Name;
_settingsService.Save(settings);

//StrongReferenceMessenger.Default.Send<SitemapChanged>(new SitemapChanged(value.Model));
StrongReferenceMessenger.Default.Register<WidgetNavigationMessage, string>(this, SelectedSitemap.Name, (obj, operation)
=> WidgetNavigatedEvent());
}

SelectedMenuItem = value;
Expand Down
16 changes: 8 additions & 8 deletions src/openHAB.Windows/ViewModel/SitemapViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Threading.Tasks;
using CommunityToolkit.Mvvm.Messaging;
using CommunityToolkit.WinUI;
using openHAB.Common;
Expand All @@ -14,6 +9,11 @@
using openHAB.Core.Services;
using openHAB.Windows.Messages;
using openHAB.Windows.Services;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Threading.Tasks;

namespace openHAB.Windows.ViewModel
{
Expand Down Expand Up @@ -69,7 +69,7 @@ private SitemapViewModel(Sitemap model, List<WidgetViewModel> widgetViewModels)
StrongReferenceMessenger.Default.Register<DataOperation>(this, (obj, operation)
=> DataOperationState(operation));

StrongReferenceMessenger.Default.Register<WidgetNavigationMessage>(this, (recipient, msg) =>
StrongReferenceMessenger.Default.Register<WidgetNavigationMessage, string>(this, Model.Name, (recipient, msg) =>
{
if (msg.Trigger == EventTriggerSource.Breadcrumb)
{
Expand Down Expand Up @@ -369,7 +369,7 @@ await App.DispatcherQueue.EnqueueAsync(async () =>
}
WidgetNavigationService.Navigate(SelectedWidget);
StrongReferenceMessenger.Default.Send(new WidgetNavigationMessage(lastWidget, widget, EventTriggerSource.Widget));
StrongReferenceMessenger.Default.Send(new WidgetNavigationMessage(lastWidget, widget, EventTriggerSource.Widget), Model.Name);
List<WidgetViewModel> widgets = ConvertWidgetToViewModel(SelectedWidget.LinkedPage.Widgets);
await SetWidgetsOnScreenAsync(widgets);
Expand Down Expand Up @@ -402,7 +402,7 @@ private async Task WidgetGoBack(WidgetViewModel widget)

SelectedWidget = widgetFromStack;
WidgetNavigationService.Navigate(SelectedWidget);
StrongReferenceMessenger.Default.Send(new WidgetNavigationMessage(lastWidget, SelectedWidget, EventTriggerSource.Widget));
StrongReferenceMessenger.Default.Send(new WidgetNavigationMessage(lastWidget, SelectedWidget, EventTriggerSource.Widget), Model.Name);

List<WidgetViewModel> widgets = ConvertWidgetToViewModel(SelectedWidget.LinkedPage.Widgets);
await SetWidgetsOnScreenAsync(widgets);
Expand Down

This file was deleted.

0 comments on commit f0630f2

Please sign in to comment.