Skip items that are not enabled when creating jump list (#1333)

* Fix jumplist bug

* Add extra check
This commit is contained in:
Pepe Rivera 2020-08-06 12:28:38 -07:00 committed by GitHub
parent 3309380907
commit 258833f266
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 1 deletions

View File

@ -75,7 +75,7 @@ void ApplicationViewModel::Categories::set(IObservableVector<NavCategoryGroup ^>
void ApplicationViewModel::Initialize(ViewMode mode)
{
if (!NavCategory::IsValidViewMode(mode))
if (!NavCategory::IsValidViewMode(mode) || !NavCategory::IsViewModeEnabled(mode))
{
mode = ViewMode::Standard;
}

View File

@ -350,6 +350,14 @@ bool NavCategory::IsValidViewMode(ViewMode mode)
return iter != s_categoryManifest.end();
}
bool NavCategory::IsViewModeEnabled(ViewMode mode)
{
auto iter =
find_if(begin(s_categoryManifest), end(s_categoryManifest), [mode](const NavCategoryInitializer& initializer) { return initializer.viewMode == mode && initializer.isEnabled; });
return iter != s_categoryManifest.end();
}
bool NavCategory::IsCalculatorViewMode(ViewMode mode)
{
// Historically, Calculator modes are Standard, Scientific, and Programmer.

View File

@ -134,6 +134,7 @@ namespace CalculatorApp
static ViewMode GetViewModeForFriendlyName(Platform::String ^ name);
static bool IsValidViewMode(ViewMode mode);
static bool IsViewModeEnabled(ViewMode mode);
static bool IsCalculatorViewMode(ViewMode mode);
static bool IsGraphingCalculatorViewMode(ViewMode mode);
static bool IsDateCalculatorViewMode(ViewMode mode);

View File

@ -148,6 +148,10 @@ task<void> App::SetupJumpList()
for (NavCategory ^ option : calculatorOptions->Categories)
{
if (!option->IsEnabled)
{
continue;
}
ViewMode mode = option->Mode;
auto item = JumpListItem::CreateWithArguments(((int)mode).ToString(), L"ms-resource:///Resources/" + NavCategory::GetNameResourceKey(mode));
item->Description = L"ms-resource:///Resources/" + NavCategory::GetNameResourceKey(mode);