mirror of
https://github.com/Microsoft/calculator.git
synced 2025-08-21 05:43:10 -07:00
simplify the graphing test
This commit is contained in:
parent
b293c00d0f
commit
d3f9bc0363
1 changed files with 9 additions and 20 deletions
|
@ -50,34 +50,24 @@ static constexpr int GRAPHING_ID = 17;
|
||||||
namespace // put the utils within this TU
|
namespace // put the utils within this TU
|
||||||
{
|
{
|
||||||
Platform::String^ CurrentUserId;
|
Platform::String^ CurrentUserId;
|
||||||
std::mutex GraphingModeCheckMutex;
|
|
||||||
|
|
||||||
bool IsGraphingModeEnabled()
|
bool IsGraphingModeEnabled()
|
||||||
{
|
{
|
||||||
static bool isChecked = false;
|
static auto enabled = []
|
||||||
static bool isEnabled = false;
|
|
||||||
|
|
||||||
std::scoped_lock<std::mutex> lock(GraphingModeCheckMutex);
|
|
||||||
if (isChecked)
|
|
||||||
{
|
{
|
||||||
return isEnabled;
|
if (CurrentUserId == nullptr)
|
||||||
|
{
|
||||||
|
throw std::logic_error{ "SetCurrentUser must be invoked at least once." };
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
auto user = User::GetFromId(CurrentUserId);
|
auto user = User::GetFromId(CurrentUserId);
|
||||||
if (user == nullptr)
|
if (user == nullptr)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
return NamedPolicy::GetPolicyFromPathForUser(user, L"Education", L"AllowGraphingCalculator")->GetBoolean();
|
||||||
auto namedPolicyData = NamedPolicy::GetPolicyFromPathForUser(
|
}();
|
||||||
user,
|
return enabled;
|
||||||
L"Education",
|
|
||||||
L"AllowGraphingCalculator");
|
|
||||||
isEnabled = namedPolicyData->GetBoolean();
|
|
||||||
isChecked = true;
|
|
||||||
return isEnabled;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// The order of items in this list determines the order of items in the menu.
|
// The order of items in this list determines the order of items in the menu.
|
||||||
|
@ -318,7 +308,6 @@ NavCategoryGroup::NavCategoryGroup(const NavCategoryGroupInitializer& groupIniti
|
||||||
|
|
||||||
void NavCategoryStates::SetCurrentUser(Platform::String^ userId)
|
void NavCategoryStates::SetCurrentUser(Platform::String^ userId)
|
||||||
{
|
{
|
||||||
std::scoped_lock<std::mutex> lock(GraphingModeCheckMutex);
|
|
||||||
CurrentUserId = userId;
|
CurrentUserId = userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue