From c1c6afb0f48e9cc8852448a0826263810f7a5cae Mon Sep 17 00:00:00 2001 From: Robyn MacCallum Date: Fri, 19 Apr 2024 09:45:09 -0400 Subject: [PATCH] [PM-7562] Add DuckDuckGo back to State Service (#8791) * Add ddg back to state service * Remove getters --- .../desktop/src/app/accounts/settings.component.ts | 5 +++++ .../src/platform/abstractions/state.service.ts | 7 +++++++ .../src/platform/models/domain/global-state.ts | 1 + libs/common/src/platform/services/state.service.ts | 14 ++++++++++++++ 4 files changed, 27 insertions(+) diff --git a/apps/desktop/src/app/accounts/settings.component.ts b/apps/desktop/src/app/accounts/settings.component.ts index 06533e18fc..f3958d7c87 100644 --- a/apps/desktop/src/app/accounts/settings.component.ts +++ b/apps/desktop/src/app/accounts/settings.component.ts @@ -660,6 +660,11 @@ export class SettingsComponent implements OnInit { this.form.value.enableDuckDuckGoBrowserIntegration, ); + // Adding to cover users on a previous version of DDG + await this.stateService.setEnableDuckDuckGoBrowserIntegration( + this.form.value.enableDuckDuckGoBrowserIntegration, + ); + if (!this.form.value.enableBrowserIntegration) { await this.stateService.setDuckDuckGoSharedKey(null); } diff --git a/libs/common/src/platform/abstractions/state.service.ts b/libs/common/src/platform/abstractions/state.service.ts index 2348c8844a..27026ac0ea 100644 --- a/libs/common/src/platform/abstractions/state.service.ts +++ b/libs/common/src/platform/abstractions/state.service.ts @@ -74,6 +74,13 @@ export abstract class StateService { * Used when Lock with MP on Restart is enabled */ setPinKeyEncryptedUserKeyEphemeral: (value: EncString, options?: StorageOptions) => Promise; + /** + * @deprecated For backwards compatible purposes only, use DesktopAutofillSettingsService + */ + setEnableDuckDuckGoBrowserIntegration: ( + value: boolean, + options?: StorageOptions, + ) => Promise; /** * @deprecated For migration purposes only, use getUserKeyMasterKey instead */ diff --git a/libs/common/src/platform/models/domain/global-state.ts b/libs/common/src/platform/models/domain/global-state.ts index 703a998d1c..cd7cf7d174 100644 --- a/libs/common/src/platform/models/domain/global-state.ts +++ b/libs/common/src/platform/models/domain/global-state.ts @@ -4,4 +4,5 @@ export class GlobalState { vaultTimeoutAction?: string; enableBrowserIntegration?: boolean; enableBrowserIntegrationFingerprint?: boolean; + enableDuckDuckGoBrowserIntegration?: boolean; } diff --git a/libs/common/src/platform/services/state.service.ts b/libs/common/src/platform/services/state.service.ts index 9edc9ed1e3..1fb2d71670 100644 --- a/libs/common/src/platform/services/state.service.ts +++ b/libs/common/src/platform/services/state.service.ts @@ -571,6 +571,20 @@ export class StateService< ); } + async setEnableDuckDuckGoBrowserIntegration( + value: boolean, + options?: StorageOptions, + ): Promise { + const globals = await this.getGlobals( + this.reconcileOptions(options, await this.defaultOnDiskOptions()), + ); + globals.enableDuckDuckGoBrowserIntegration = value; + await this.saveGlobals( + globals, + this.reconcileOptions(options, await this.defaultOnDiskOptions()), + ); + } + /** * @deprecated Use UserKey instead */