|
2872 | 2872 | "duckPlayer", |
2873 | 2873 | "duckPlayerNative", |
2874 | 2874 | "duckAiListener", |
| 2875 | + "duckAiDataClearing", |
2875 | 2876 | "harmfulApis", |
2876 | 2877 | "webCompat", |
2877 | 2878 | "windowsPermissionUsage", |
|
2885 | 2886 | ] |
2886 | 2887 | ); |
2887 | 2888 | var platformSupport = { |
2888 | | - apple: ["webCompat", "duckPlayerNative", ...baseFeatures, "duckAiListener", "pageContext"], |
| 2889 | + apple: ["webCompat", "duckPlayerNative", ...baseFeatures, "duckAiListener", "duckAiDataClearing", "pageContext"], |
2889 | 2890 | "apple-isolated": [ |
2890 | 2891 | "duckPlayer", |
2891 | 2892 | "duckPlayerNative", |
|
2895 | 2896 | "messageBridge", |
2896 | 2897 | "favicon" |
2897 | 2898 | ], |
2898 | | - android: [...baseFeatures, "webCompat", "breakageReporting", "duckPlayer", "messageBridge"], |
| 2899 | + android: [...baseFeatures, "webCompat", "breakageReporting", "duckPlayer", "messageBridge", "duckAiDataClearing"], |
2899 | 2900 | "android-broker-protection": ["brokerProtection"], |
2900 | 2901 | "android-autofill-password-import": ["autofillPasswordImport"], |
2901 | 2902 | "android-adsjs": [ |
|
2920 | 2921 | "messageBridge", |
2921 | 2922 | "webCompat", |
2922 | 2923 | "pageContext", |
2923 | | - "duckAiListener" |
| 2924 | + "duckAiListener", |
| 2925 | + "duckAiDataClearing" |
2924 | 2926 | ], |
2925 | 2927 | firefox: ["cookie", ...baseFeatures, "clickToLoad"], |
2926 | 2928 | chrome: ["cookie", ...baseFeatures, "clickToLoad"], |
@@ -15657,6 +15659,70 @@ ${truncatedWarning} |
15657 | 15659 | __publicField(_DuckAiPromptTelemetry, "ONE_DAY_MS", 24 * 60 * 60 * 1e3); |
15658 | 15660 | var DuckAiPromptTelemetry = _DuckAiPromptTelemetry; |
15659 | 15661 |
|
| 15662 | + // src/features/duck-ai-data-clearing.js |
| 15663 | + init_define_import_meta_trackerLookup(); |
| 15664 | + var DuckAiDataClearing = class extends ContentFeature { |
| 15665 | + init() { |
| 15666 | + this.messaging.subscribe("duckAiClearData", (_2) => this.clearData()); |
| 15667 | + } |
| 15668 | + async clearData() { |
| 15669 | + let success = true; |
| 15670 | + try { |
| 15671 | + this.clearSavedAIChats(); |
| 15672 | + } catch (error) { |
| 15673 | + success = false; |
| 15674 | + this.log.error("Error clearing `savedAIChats`:", error); |
| 15675 | + } |
| 15676 | + try { |
| 15677 | + await this.clearChatImagesStore(); |
| 15678 | + } catch (error) { |
| 15679 | + success = false; |
| 15680 | + this.log.error("Error clearing `chat-images` object store:", error); |
| 15681 | + } |
| 15682 | + if (success) { |
| 15683 | + this.notify("duckAiClearDataCompleted"); |
| 15684 | + } else { |
| 15685 | + this.notify("duckAiClearDataFailed"); |
| 15686 | + } |
| 15687 | + } |
| 15688 | + clearSavedAIChats() { |
| 15689 | + this.log.info("Clearing `savedAIChats`"); |
| 15690 | + window.localStorage.removeItem("savedAIChats"); |
| 15691 | + } |
| 15692 | + async clearChatImagesStore() { |
| 15693 | + this.log.info("Clearing `chat-images` object store"); |
| 15694 | + return new Promise((resolve, reject) => { |
| 15695 | + const request = window.indexedDB.open("savedAIChatData"); |
| 15696 | + request.onerror = (event) => { |
| 15697 | + this.log.error("Error opening IndexedDB:", event); |
| 15698 | + reject(event); |
| 15699 | + }; |
| 15700 | + request.onsuccess = (_2) => { |
| 15701 | + const db = request.result; |
| 15702 | + if (!db) { |
| 15703 | + this.log.error("IndexedDB onsuccess but no db result"); |
| 15704 | + reject(new Error("No DB result")); |
| 15705 | + return; |
| 15706 | + } |
| 15707 | + try { |
| 15708 | + const transaction = db.transaction(["chat-images"], "readwrite"); |
| 15709 | + const objectStore = transaction.objectStore("chat-images"); |
| 15710 | + const clearRequest = objectStore.clear(); |
| 15711 | + clearRequest.onsuccess = () => resolve(null); |
| 15712 | + clearRequest.onerror = (err) => { |
| 15713 | + this.log.error("Error clearing object store:", err); |
| 15714 | + reject(err); |
| 15715 | + }; |
| 15716 | + } catch (err) { |
| 15717 | + this.log.error("Exception during IndexedDB clearing:", err); |
| 15718 | + reject(err); |
| 15719 | + } |
| 15720 | + }; |
| 15721 | + }); |
| 15722 | + } |
| 15723 | + }; |
| 15724 | + var duck_ai_data_clearing_default = DuckAiDataClearing; |
| 15725 | + |
15660 | 15726 | // src/features/harmful-apis.js |
15661 | 15727 | init_define_import_meta_trackerLookup(); |
15662 | 15728 | var HarmfulApis = class extends ContentFeature { |
@@ -21830,6 +21896,7 @@ ${children} |
21830 | 21896 | ddg_feature_duckPlayer: DuckPlayerFeature, |
21831 | 21897 | ddg_feature_duckPlayerNative: duck_player_native_default, |
21832 | 21898 | ddg_feature_duckAiListener: DuckAiListener, |
| 21899 | + ddg_feature_duckAiDataClearing: duck_ai_data_clearing_default, |
21833 | 21900 | ddg_feature_harmfulApis: HarmfulApis, |
21834 | 21901 | ddg_feature_webCompat: web_compat_default, |
21835 | 21902 | ddg_feature_windowsPermissionUsage: WindowsPermissionUsage, |
|
0 commit comments