@@ -14,18 +14,24 @@ export class DuckAiDataClearing extends ContentFeature {
1414 async clearData ( ) {
1515 let success = true ;
1616
17- try {
18- this . clearSavedAIChats ( ) ;
19- } catch ( error ) {
20- success = false ;
21- this . log . error ( 'Error clearing saved chats:' , error ) ;
17+ const localStorageKeys = this . getFeatureSetting ( 'chatsLocalStorageKeys' ) ;
18+ for ( const localStorageKey of localStorageKeys ) {
19+ try {
20+ this . clearSavedAIChats ( localStorageKey ) ;
21+ } catch ( error ) {
22+ success = false ;
23+ this . log . error ( 'Error clearing saved chats:' , error ) ;
24+ }
2225 }
2326
24- try {
25- await this . clearChatImagesStore ( ) ;
26- } catch ( error ) {
27- success = false ;
28- this . log . error ( 'Error clearing saved chat images:' , error ) ;
27+ const indexDbNameObjectStoreNamePairs = this . getFeatureSetting ( 'chatImagesIndexDbNameObjectStoreNamePairs' ) ;
28+ for ( const [ indexDbName , objectStoreName ] of indexDbNameObjectStoreNamePairs ) {
29+ try {
30+ await this . clearChatImagesStore ( indexDbName , objectStoreName ) ;
31+ } catch ( error ) {
32+ success = false ;
33+ this . log . error ( 'Error clearing saved chat images:' , error ) ;
34+ }
2935 }
3036
3137 if ( success ) {
@@ -35,17 +41,12 @@ export class DuckAiDataClearing extends ContentFeature {
3541 }
3642 }
3743
38- clearSavedAIChats ( ) {
39- const localStorageKey = this . getFeatureSetting ( 'chatsLocalStorageKey' ) ;
40-
44+ clearSavedAIChats ( localStorageKey ) {
4145 this . log . info ( `Clearing '${ localStorageKey } '` ) ;
4246 window . localStorage . removeItem ( localStorageKey ) ;
4347 }
4448
45- clearChatImagesStore ( ) {
46- const indexDbName = this . getFeatureSetting ( 'chatImagesIndexDbName' ) ;
47- const objectStoreName = this . getFeatureSetting ( 'chatImagesObjectStoreName' ) ;
48-
49+ clearChatImagesStore ( indexDbName , objectStoreName ) {
4950 this . log . info ( `Clearing '${ indexDbName } ' object store` ) ;
5051
5152 return new Promise ( ( resolve , reject ) => {
0 commit comments