@@ -18,14 +18,14 @@ export class DuckAiDataClearing extends ContentFeature {
1818 this . clearSavedAIChats ( ) ;
1919 } catch ( error ) {
2020 success = false ;
21- this . log . error ( 'Error clearing `savedAIChats` :' , error ) ;
21+ this . log . error ( 'Error clearing saved chats :' , error ) ;
2222 }
2323
2424 try {
2525 await this . clearChatImagesStore ( ) ;
2626 } catch ( error ) {
2727 success = false ;
28- this . log . error ( 'Error clearing ` chat-images` object store :' , error ) ;
28+ this . log . error ( 'Error clearing saved chat images :' , error ) ;
2929 }
3030
3131 if ( success ) {
@@ -36,16 +36,20 @@ export class DuckAiDataClearing extends ContentFeature {
3636 }
3737
3838 clearSavedAIChats ( ) {
39- this . log . info ( 'Clearing `savedAIChats` ') ;
39+ const localStorageKey = this . getFeatureSetting ( 'chatsLocalStorageKey ') ;
4040
41- window . localStorage . removeItem ( 'savedAIChats' ) ;
41+ this . log . info ( `Clearing '${ localStorageKey } '` ) ;
42+ window . localStorage . removeItem ( localStorageKey ) ;
4243 }
4344
4445 clearChatImagesStore ( ) {
45- this . log . info ( 'Clearing `chat-images` object store' ) ;
46+ const indexDbName = this . getFeatureSetting ( 'chatImagesIndexDbName' ) ;
47+ const objectStoreName = this . getFeatureSetting ( 'chatImagesObjectStoreName' ) ;
48+
49+ this . log . info ( `Clearing '${ indexDbName } ' object store` ) ;
4650
4751 return new Promise ( ( resolve , reject ) => {
48- const request = window . indexedDB . open ( 'savedAIChatData' ) ;
52+ const request = window . indexedDB . open ( indexDbName ) ;
4953 request . onerror = ( event ) => {
5054 this . log . error ( 'Error opening IndexedDB:' , event ) ;
5155 reject ( event ) ;
@@ -59,16 +63,16 @@ export class DuckAiDataClearing extends ContentFeature {
5963 }
6064
6165 // Check if the object store exists
62- if ( ! db . objectStoreNames . contains ( 'chat-images' ) ) {
63- this . log . info ( 'chat-images object store does not exist, nothing to clear' ) ;
66+ if ( ! db . objectStoreNames . contains ( objectStoreName ) ) {
67+ this . log . info ( `' ${ objectStoreName } ' object store does not exist, nothing to clear` ) ;
6468 db . close ( ) ;
6569 resolve ( null ) ;
6670 return ;
6771 }
6872
6973 try {
70- const transaction = db . transaction ( [ 'chat-images' ] , 'readwrite' ) ;
71- const objectStore = transaction . objectStore ( 'chat-images' ) ;
74+ const transaction = db . transaction ( [ objectStoreName ] , 'readwrite' ) ;
75+ const objectStore = transaction . objectStore ( objectStoreName ) ;
7276 const clearRequest = objectStore . clear ( ) ;
7377 clearRequest . onsuccess = ( ) => {
7478 db . close ( ) ;
0 commit comments