Skip to content

Commit

Permalink
Hide disabled widgets (#3253)
Browse files Browse the repository at this point in the history
  • Loading branch information
krschau authored Jun 19, 2024
1 parent d3203b2 commit b9c628e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
4 changes: 2 additions & 2 deletions tools/Dashboard/DevHome.Dashboard/Helpers/WidgetHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ public static async Task<bool> IsIncludedWidgetProviderAsync(WidgetProviderDefin
var endOfPfnIndex = providerId.IndexOf('!', StringComparison.Ordinal);
var familyNamePartOfProviderId = providerId[..endOfPfnIndex];

// Get the list of packages that contain Dev Home widgets.
// Get the list of packages that contain Dev Home widgets and are enabled.
var extensionService = Application.Current.GetService<IExtensionService>();
var enabledWidgetProviderIds = await extensionService.GetInstalledDevHomeWidgetPackageFamilyNamesAsync(true);
var enabledWidgetProviderIds = await extensionService.GetInstalledDevHomeWidgetPackageFamilyNamesAsync(includeDisabledExtensions: false);

// Check if the specified widget provider is in the list.
var include = enabledWidgetProviderIds.ToList().Contains(familyNamePartOfProviderId);
Expand Down
2 changes: 1 addition & 1 deletion tools/Dashboard/DevHome.Dashboard/Views/DashboardView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
</Grid>

<ScrollViewer VerticalScrollBarVisibility="Auto" Grid.Row="1">
<!-- This Grid helps keep the content centered -->
<!-- This Grid helps keep the content centered -->
<Grid>
<StackPanel MaxWidth="{ThemeResource MaxPageContentWidth}" Margin="{ThemeResource ContentPageMargin}">
<!-- Top Banner - Default/First run experience - shown until user dismissed -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,6 @@ private async Task RestorePinnedWidgetsAsync(ComSafeWidget[] hostWidgets)
continue;
}

// Ensure only one copy of a widget is pinned if that widget's definition only allows for one instance.
var comSafeWidgetDefinition = new ComSafeWidgetDefinition(widgetDefinitionId);
if (!await comSafeWidgetDefinition.PopulateAsync())
{
Expand All @@ -311,6 +310,14 @@ private async Task RestorePinnedWidgetsAsync(ComSafeWidget[] hostWidgets)
continue;
}

// If the widget's extension was disabled, hide the widget (don't add it to the list), but don't delete it.
if (!await WidgetHelpers.IsIncludedWidgetProviderAsync(comSafeWidgetDefinition.ProviderDefinition))
{
_log.Information($"Not adding widget from disabled extension {comSafeWidgetDefinition.ProviderDefinitionId}");
continue;
}

// Ensure only one copy of a widget is pinned if that widget's definition only allows for one instance.
if (comSafeWidgetDefinition.AllowMultiple == false)
{
if (pinnedSingleInstanceWidgets.Contains(widgetDefinitionId))
Expand Down

0 comments on commit b9c628e

Please sign in to comment.