Skip to content

Commit

Permalink
refactor: merged generateTabId with getTabId
Browse files Browse the repository at this point in the history
  • Loading branch information
michal-oleniacz-stp committed Apr 11, 2024
1 parent 44f515c commit c072525
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions src/identity.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,19 +209,6 @@ export class Identity extends EventEmitter {
this._setGlobalSessionServiceUrl(env);

this._unblockSessionCall();
this._generateTabId();
}

/**
* Generates browser tab ID if it's not present in cache
* @private
*/
_generateTabId() {
if (this._enableSessionCaching) {
if (!this.cache.get(TAB_ID_KEY)) {
this.cache.set(TAB_ID_KEY, TAB_ID, TAB_ID_TTL)
}
}
}

/**
Expand All @@ -231,7 +218,13 @@ export class Identity extends EventEmitter {
*/
_getTabId() {
if (this._enableSessionCaching) {
return this.cache.get(TAB_ID_KEY)
const tabId = this.cache.get(TAB_ID_KEY);
if (!tabId) {
this.cache.set(TAB_ID_KEY, TAB_ID, TAB_ID_TTL);
return TAB_ID;
}

return tabId;
}
}

Expand Down

0 comments on commit c072525

Please sign in to comment.