Skip to content

Commit 7cf6e7b

Browse files
committed
fix: entitlments cache misses for valid null entitlement
1 parent 4ae38ca commit 7cf6e7b

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/services/EntitlementsManager.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,13 @@ define(function (require, exports, module) {
7373
});
7474
}
7575

76-
let effectiveEntitlements = null;
76+
let effectiveEntitlementsCached = undefined; // entitlements can be null and its valid if no login/trial
7777
async function _getEffectiveEntitlements() {
78-
if(effectiveEntitlements){
79-
return effectiveEntitlements;
78+
if(effectiveEntitlementsCached !== undefined){
79+
return effectiveEntitlementsCached;
8080
}
8181
const entitlements = await LoginService.getEffectiveEntitlements();
82-
effectiveEntitlements = entitlements;
82+
effectiveEntitlementsCached = entitlements;
8383
return entitlements;
8484
}
8585

@@ -178,7 +178,7 @@ define(function (require, exports, module) {
178178
LoginService = KernalModeTrust.loginService;
179179
// Set up event forwarding from LoginService
180180
LoginService.on(LoginService.EVENT_ENTITLEMENTS_CHANGED, function() {
181-
effectiveEntitlements = null;
181+
effectiveEntitlementsCached = null;
182182
EntitlementsManager.trigger(EVENT_ENTITLEMENTS_CHANGED);
183183
});
184184
AIControl.init();

src/services/login-service.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ define(function (require, exports, module) {
7272
const EVENT_ENTITLEMENTS_CHANGED = "entitlements_changed";
7373

7474
// Cached entitlements data
75-
let cachedEntitlements = null;
75+
let cachedEntitlements = undefined;
7676

7777
// Last recorded state for entitlements monitoring
7878
let lastRecordedState = null;
@@ -266,7 +266,7 @@ define(function (require, exports, module) {
266266
}
267267

268268
// Return cached data if available and not forcing refresh
269-
if (cachedEntitlements && !forceRefresh) {
269+
if (cachedEntitlements !== undefined && !forceRefresh) {
270270
return cachedEntitlements;
271271
}
272272

@@ -388,7 +388,7 @@ define(function (require, exports, module) {
388388
*/
389389
async function clearEntitlements() {
390390
if (cachedEntitlements) {
391-
cachedEntitlements = null;
391+
cachedEntitlements = undefined;
392392
_debounceEntitlementsChanged();
393393
}
394394
// Reset device license state so it's re-evaluated on next entitlement check

0 commit comments

Comments
 (0)