From 332f12cbb14c20b59d3244ea0e1214ead46a108b Mon Sep 17 00:00:00 2001 From: amitjoshi Date: Tue, 10 Sep 2024 18:21:23 +0530 Subject: [PATCH] refactor: Remove unused parameter in initializeOrgDetails function --- .../powerpages/PowerPagesChatParticipant.ts | 4 ++-- src/common/utilities/OrgHandlerUtils.ts | 19 ++++--------------- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/src/common/chat-participants/powerpages/PowerPagesChatParticipant.ts b/src/common/chat-participants/powerpages/PowerPagesChatParticipant.ts index 7947c7ebb..85de5fbcd 100644 --- a/src/common/chat-participants/powerpages/PowerPagesChatParticipant.ts +++ b/src/common/chat-participants/powerpages/PowerPagesChatParticipant.ts @@ -227,7 +227,7 @@ export class PowerPagesChatParticipant { private async initializeOrgDetails(): Promise { try { - const { orgID, orgUrl, environmentID } = await initializeOrgDetails(this.isOrgDetailsInitialized, this.extensionContext, this._pacWrapper); + const { orgID, orgUrl, environmentID } = await initializeOrgDetails(this.isOrgDetailsInitialized, this._pacWrapper); if (!orgID) { return; @@ -242,7 +242,7 @@ export class PowerPagesChatParticipant { } private async handleOrgChangeSuccess(orgDetails: ActiveOrgOutput): Promise { - const { orgID, orgUrl, environmentID } = handleOrgChangeSuccess(orgDetails, this.extensionContext); + const { orgID, orgUrl, environmentID } = handleOrgChangeSuccess(orgDetails); this.orgID = orgID; this.orgUrl = orgUrl; this.environmentID = environmentID; diff --git a/src/common/utilities/OrgHandlerUtils.ts b/src/common/utilities/OrgHandlerUtils.ts index 11df49592..f6f492416 100644 --- a/src/common/utilities/OrgHandlerUtils.ts +++ b/src/common/utilities/OrgHandlerUtils.ts @@ -3,7 +3,6 @@ * Licensed under the MIT License. See License.txt in the project root for license information. */ -import { ExtensionContext } from 'vscode'; import { ActiveOrgOutput } from '../../client/pac/PacTypes'; import { PacWrapper } from '../../client/pac/PacWrapper'; import { IOrgDetails } from '../chat-participants/powerpages/PowerPagesChatParticipantTypes'; @@ -15,26 +14,22 @@ export const ORG_DETAILS_KEY = 'orgDetails'; export function handleOrgChangeSuccess( orgDetails: ActiveOrgOutput, - extensionContext: ExtensionContext ): IOrgDetails { const { OrgId: orgID, OrgUrl: orgUrl, EnvironmentId: environmentID } = orgDetails; - extensionContext.globalState.update(ORG_DETAILS_KEY, { orgID, orgUrl, environmentID }); - return { orgID, orgUrl, environmentID }; } -async function fetchOrgDetailsFromPac(pacWrapper: PacWrapper, extensionContext: ExtensionContext): Promise { +async function fetchOrgDetailsFromPac(pacWrapper: PacWrapper): Promise { const pacActiveOrg = await pacWrapper.activeOrg(); if (pacActiveOrg && pacActiveOrg.Status === SUCCESS) { - return handleOrgChangeSuccess(pacActiveOrg.Results, extensionContext); + return handleOrgChangeSuccess(pacActiveOrg.Results); } throw new Error(ERROR_CONSTANTS.PAC_AUTH_FAILED); } export async function initializeOrgDetails( isOrgDetailsInitialized: boolean, - extensionContext: ExtensionContext, pacWrapper?: PacWrapper ): Promise { const orgDetails: IOrgDetails = { orgID: '', orgUrl: '', environmentID: '' }; @@ -43,21 +38,15 @@ export async function initializeOrgDetails( return orgDetails; } - // Get stored organization details from global state - const storedOrgDetails: IOrgDetails | undefined = extensionContext.globalState.get(ORG_DETAILS_KEY); - if (storedOrgDetails && storedOrgDetails.orgID && storedOrgDetails.orgUrl && storedOrgDetails.environmentID) { - return storedOrgDetails; - } - if (pacWrapper) { try { - const fetchedOrgDetails = await fetchOrgDetailsFromPac(pacWrapper, extensionContext); + const fetchedOrgDetails = await fetchOrgDetailsFromPac(pacWrapper); orgDetails.orgID = fetchedOrgDetails.orgID; orgDetails.orgUrl = fetchedOrgDetails.orgUrl; orgDetails.environmentID = fetchedOrgDetails.environmentID; } catch (error) { await createAuthProfileExp(pacWrapper); - const fetchedOrgDetails = await fetchOrgDetailsFromPac(pacWrapper, extensionContext); + const fetchedOrgDetails = await fetchOrgDetailsFromPac(pacWrapper); orgDetails.orgID = fetchedOrgDetails.orgID; orgDetails.orgUrl = fetchedOrgDetails.orgUrl; orgDetails.environmentID = fetchedOrgDetails.environmentID;