Skip to content

Commit b8d6537

Browse files
krschauEricJohnson327
authored andcommitted
Disallow user from adding widgets if the WidgetService isn't started (#3632)
1 parent 25c1167 commit b8d6537

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

tools/Dashboard/DevHome.Dashboard/Services/WidgetHostingService.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public async Task<WidgetCatalog> GetWidgetCatalogAsync()
131131
}
132132
catch (Exception ex)
133133
{
134-
_log.Error(ex, "Exception in GetWidgetDefinitionAsync:");
134+
_log.Error(ex, "Exception in GetWidgetCatalogAsync:");
135135
_widgetCatalog = null;
136136
}
137137
}
@@ -161,7 +161,7 @@ public async Task<WidgetProviderDefinition[]> GetProviderDefinitionsAsync()
161161
}
162162
catch (Exception ex)
163163
{
164-
_log.Error(ex, "Exception in GetWidgetDefinitionAsync:");
164+
_log.Error(ex, "Exception in GetProviderDefinitionsAsync:");
165165
}
166166
}
167167

@@ -190,7 +190,7 @@ public async Task<WidgetDefinition[]> GetWidgetDefinitionsAsync()
190190
}
191191
catch (Exception ex)
192192
{
193-
_log.Error(ex, "Exception in GetWidgetDefinitionAsync:");
193+
_log.Error(ex, "Exception in GetWidgetDefinitionsAsync:");
194194
}
195195
}
196196

tools/Dashboard/DevHome.Dashboard/ViewModels/DashboardViewModel.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public partial class DashboardViewModel : ObservableObject
2525
private bool _isLoading;
2626

2727
[ObservableProperty]
28-
private bool _hasWidgetService;
28+
private bool _hasWidgetServiceInitialized;
2929

3030
public DashboardViewModel(
3131
IWidgetServiceService widgetServiceService,
@@ -43,7 +43,7 @@ public DashboardViewModel(
4343

4444
public Visibility GetNoWidgetMessageVisibility(int widgetCount, bool isLoading)
4545
{
46-
return (widgetCount == 0 && !isLoading && HasWidgetService) ? Visibility.Visible : Visibility.Collapsed;
46+
return (widgetCount == 0 && !isLoading && HasWidgetServiceInitialized) ? Visibility.Visible : Visibility.Collapsed;
4747
}
4848

4949
public bool IsRunningAsAdmin()

tools/Dashboard/DevHome.Dashboard/Views/DashboardView.xaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
x:Uid="AddWidget"
6161
HorizontalAlignment="Right"
6262
Command="{x:Bind AddWidgetClickCommand}"
63-
IsEnabled="{x:Bind ViewModel.HasWidgetService, Mode=OneWay}"/>
63+
IsEnabled="{x:Bind ViewModel.HasWidgetServiceInitialized, Mode=OneWay}"/>
6464
</StackPanel>
6565
</Grid>
6666

tools/Dashboard/DevHome.Dashboard/Views/DashboardView.xaml.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ private async Task<bool> SubscribeToWidgetCatalogEventsAsync()
8686
var widgetCatalog = await ViewModel.WidgetHostingService.GetWidgetCatalogAsync();
8787
if (widgetCatalog == null)
8888
{
89+
_log.Error("Error in in SubscribeToWidgetCatalogEvents, widgetCatalog == null");
8990
return false;
9091
}
9192

@@ -194,9 +195,10 @@ private async Task InitializeDashboard()
194195
}
195196
else if (ViewModel.WidgetServiceService.CheckForWidgetServiceAsync())
196197
{
197-
ViewModel.HasWidgetService = true;
198198
if (await SubscribeToWidgetCatalogEventsAsync())
199199
{
200+
ViewModel.HasWidgetServiceInitialized = true;
201+
200202
var isFirstDashboardRun = !(await _localSettingsService.ReadSettingAsync<bool>(WellKnownSettingsKeys.IsNotFirstDashboardRun));
201203
_log.Information($"Is first dashboard run = {isFirstDashboardRun}");
202204
if (isFirstDashboardRun)

0 commit comments

Comments
 (0)