@@ -94,20 +94,11 @@ export const baseCustomization = {
9494 * @returns customization selected by users, `baseCustomization` if none is selected
9595 */
9696export const getSelectedCustomization = ( ) : Customization => {
97- if (
98- ! AuthUtil . instance . isCustomizationFeatureEnabled ||
99- ! AuthUtil . instance . isValidEnterpriseSsoInUse ( ) ||
100- ! AuthUtil . instance . conn
101- ) {
97+ if ( ! AuthUtil . instance . isCustomizationFeatureEnabled || ! AuthUtil . instance . isIdcConnection ( ) ) {
10298 return baseCustomization
10399 }
104100
105- const selectedCustomizationArr = globals . globalState . tryGet < { [ label : string ] : Customization } > (
106- 'CODEWHISPERER_SELECTED_CUSTOMIZATION' ,
107- Object ,
108- { }
109- )
110- const selectedCustomization = selectedCustomizationArr [ AuthUtil . instance . conn . label ]
101+ const selectedCustomization = globals . globalState . getAmazonQCustomization ( AuthUtil . instance . profileName )
111102
112103 if ( selectedCustomization && selectedCustomization . name !== '' ) {
113104 return selectedCustomization
@@ -124,7 +115,7 @@ export const getSelectedCustomization = (): Customization => {
124115 * 2. the override customization arn is different from the previous override customization if any. The purpose is to only do override once on users' behalf.
125116 */
126117export const setSelectedCustomization = async ( customization : Customization , isOverride : boolean = false ) => {
127- if ( ! AuthUtil . instance . isValidEnterpriseSsoInUse ( ) || ! AuthUtil . instance . conn ) {
118+ if ( ! AuthUtil . instance . isIdcConnection ( ) ) {
128119 return
129120 }
130121 if ( isOverride ) {
@@ -133,15 +124,10 @@ export const setSelectedCustomization = async (customization: Customization, isO
133124 return
134125 }
135126 }
136- const selectedCustomizationObj = globals . globalState . tryGet < { [ label : string ] : Customization } > (
137- 'CODEWHISPERER_SELECTED_CUSTOMIZATION' ,
138- Object ,
139- { }
140- )
141- selectedCustomizationObj [ AuthUtil . instance . conn . label ] = customization
142- getLogger ( ) . debug ( `Selected customization ${ customization . name } for ${ AuthUtil . instance . conn . label } ` )
143127
144- await globals . globalState . update ( 'CODEWHISPERER_SELECTED_CUSTOMIZATION' , selectedCustomizationObj )
128+ await globals . globalState . update ( 'CODEWHISPERER_SELECTED_CUSTOMIZATION' , customization )
129+ getLogger ( ) . debug ( `Selected customization ${ customization . name } for ${ AuthUtil . instance . profileName } ` )
130+
145131 if ( isOverride ) {
146132 await globals . globalState . update ( 'aws.amazonq.customization.overrideV2' , customization . arn )
147133 }
@@ -150,28 +136,18 @@ export const setSelectedCustomization = async (customization: Customization, isO
150136}
151137
152138export const getPersistedCustomizations = ( ) : Customization [ ] => {
153- if ( ! AuthUtil . instance . isValidEnterpriseSsoInUse ( ) || ! AuthUtil . instance . conn ) {
139+ if ( ! AuthUtil . instance . isIdcConnection ( ) ) {
154140 return [ ]
155141 }
156- const persistedCustomizationsObj = globals . globalState . tryGet < { [ label : string ] : Customization [ ] } > (
157- 'CODEWHISPERER_PERSISTED_CUSTOMIZATIONS' ,
158- Object ,
159- { }
160- )
161- return persistedCustomizationsObj [ AuthUtil . instance . conn . label ] || [ ]
142+ return globals . globalState . getAmazonQCachedCustomization ( AuthUtil . instance . profileName )
162143}
163144
164145export const setPersistedCustomizations = async ( customizations : Customization [ ] ) => {
165- if ( ! AuthUtil . instance . isValidEnterpriseSsoInUse ( ) || ! AuthUtil . instance . conn ) {
146+ if ( ! AuthUtil . instance . isIdcConnection ( ) ) {
166147 return
167148 }
168- const persistedCustomizationsObj = globals . globalState . tryGet < { [ label : string ] : Customization [ ] } > (
169- 'CODEWHISPERER_PERSISTED_CUSTOMIZATIONS' ,
170- Object ,
171- { }
172- )
173- persistedCustomizationsObj [ AuthUtil . instance . conn . label ] = customizations
174- await globals . globalState . update ( 'CODEWHISPERER_PERSISTED_CUSTOMIZATIONS' , persistedCustomizationsObj )
149+
150+ await globals . globalState . update ( 'CODEWHISPERER_PERSISTED_CUSTOMIZATIONS' , customizations )
175151}
176152
177153export const getNewCustomizationsAvailable = ( ) => {
0 commit comments