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
|
||||
{
|
||||
Platform::String^ CurrentUserId;
|
||||
std::mutex GraphingModeCheckMutex;
|
||||
|
||||
bool IsGraphingModeEnabled()
|
||||
{
|
||||
static bool isChecked = false;
|
||||
static bool isEnabled = false;
|
||||
|
||||
std::scoped_lock<std::mutex> lock(GraphingModeCheckMutex);
|
||||
if (isChecked)
|
||||
static auto enabled = []
|
||||
{
|
||||
return isEnabled;
|
||||
if (CurrentUserId == nullptr)
|
||||
{
|
||||
throw std::logic_error{ "SetCurrentUser must be invoked at least once." };
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
auto user = User::GetFromId(CurrentUserId);
|
||||
if (user == nullptr)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
auto namedPolicyData = NamedPolicy::GetPolicyFromPathForUser(
|
||||
user,
|
||||
L"Education",
|
||||
L"AllowGraphingCalculator");
|
||||
isEnabled = namedPolicyData->GetBoolean();
|
||||
isChecked = true;
|
||||
return isEnabled;
|
||||
}
|
||||
return NamedPolicy::GetPolicyFromPathForUser(user, L"Education", L"AllowGraphingCalculator")->GetBoolean();
|
||||
}();
|
||||
return enabled;
|
||||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
std::scoped_lock<std::mutex> lock(GraphingModeCheckMutex);
|
||||
CurrentUserId = userId;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue