Skip to content

Commit f5794a2

Browse files
committed
Address PR review feedback
1 parent 9a95135 commit f5794a2

File tree

4 files changed

+21
-22
lines changed

4 files changed

+21
-22
lines changed

injected/integration-test/test-pages/duck-ai-data-clearing/config/enabled.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
"duckAiDataClearing": {
66
"state": "enabled",
77
"settings": {
8-
"chatsLocalStorageKey": "savedAIChats",
9-
"chatImagesIndexDbName": "savedAIChatData",
10-
"chatImagesObjectStoreName": "chat-images"
8+
"chatsLocalStorageKeys": ["savedAIChats"],
9+
"chatImagesIndexDbNameObjectStoreNamePairs": [["savedAIChatData", "chat-images"]]
1110
},
1211
"exceptions": []
1312
}

injected/playwright.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ export default defineConfig({
5252
'integration-test/duckplayer-mobile-drawer.spec.js',
5353
'integration-test/web-compat-android.spec.js',
5454
'integration-test/message-bridge-android.spec.js',
55-
'integration-test/duck-ai-data-clearing.spec.js',
5655
],
5756
use: { injectName: 'android', platform: 'android', ...devices['Galaxy S5'] },
5857
},

injected/src/features.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export const platformSupport = {
4848
'messageBridge',
4949
'favicon',
5050
],
51-
android: [...baseFeatures, 'webCompat', 'breakageReporting', 'duckPlayer', 'messageBridge', 'duckAiDataClearing'],
51+
android: [...baseFeatures, 'webCompat', 'breakageReporting', 'duckPlayer', 'messageBridge'],
5252
'android-broker-protection': ['brokerProtection'],
5353
'android-autofill-import': ['autofillImport'],
5454
'android-adsjs': [

injected/src/features/duck-ai-data-clearing.js

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)