From d6d0a919c9714d0eaa67ff10e12bfe972e8ea3d8 Mon Sep 17 00:00:00 2001 From: dddddanica Date: Thu, 28 Nov 2024 19:31:19 +0000 Subject: [PATCH] feat(27256): address better demonstration of featureFlag and error handling --- app/scripts/background.js | 11 ++++++++++- lavamoat/browserify/beta/policy.json | 4 ---- lavamoat/browserify/flask/policy.json | 4 ---- lavamoat/browserify/main/policy.json | 4 ---- lavamoat/browserify/mmi/policy.json | 4 ---- package.json | 2 +- ui/pages/settings/info-tab/info-tab.component.js | 2 +- yarn.lock | 10 +++++----- 8 files changed, 17 insertions(+), 24 deletions(-) diff --git a/app/scripts/background.js b/app/scripts/background.js index b2185718fc68..25846b6f6074 100644 --- a/app/scripts/background.js +++ b/app/scripts/background.js @@ -892,7 +892,7 @@ export function setupController( controller.setupTrustedCommunication(portStream, remotePort.sender); // initialize the request to fetch remote feature flags - controller.remoteFeatureFlagController.updateRemoteFeatureFlags(); + initializeRemoteFeatureFlags(); if (processName === ENVIRONMENT_TYPE_POPUP) { openPopupCount += 1; @@ -1096,6 +1096,15 @@ export function setupController( } } + function initializeRemoteFeatureFlags() { + try { + // initialize the request to fetch remote feature flags + controller.remoteFeatureFlagController.updateRemoteFeatureFlags(); + } catch (error) { + console.error('Error initializing remote feature flags:', error); + } + } + function getPendingApprovalCount() { try { let pendingApprovalCount = diff --git a/lavamoat/browserify/beta/policy.json b/lavamoat/browserify/beta/policy.json index 8026f7d4eead..b5a1141cb480 100644 --- a/lavamoat/browserify/beta/policy.json +++ b/lavamoat/browserify/beta/policy.json @@ -2384,12 +2384,8 @@ } }, "@metamask/remote-feature-flag-controller": { - "globals": { - "console.error": true - }, "packages": { "@metamask/base-controller": true, - "@metamask/utils": true, "cockatiel": true } }, diff --git a/lavamoat/browserify/flask/policy.json b/lavamoat/browserify/flask/policy.json index 8026f7d4eead..b5a1141cb480 100644 --- a/lavamoat/browserify/flask/policy.json +++ b/lavamoat/browserify/flask/policy.json @@ -2384,12 +2384,8 @@ } }, "@metamask/remote-feature-flag-controller": { - "globals": { - "console.error": true - }, "packages": { "@metamask/base-controller": true, - "@metamask/utils": true, "cockatiel": true } }, diff --git a/lavamoat/browserify/main/policy.json b/lavamoat/browserify/main/policy.json index 8026f7d4eead..b5a1141cb480 100644 --- a/lavamoat/browserify/main/policy.json +++ b/lavamoat/browserify/main/policy.json @@ -2384,12 +2384,8 @@ } }, "@metamask/remote-feature-flag-controller": { - "globals": { - "console.error": true - }, "packages": { "@metamask/base-controller": true, - "@metamask/utils": true, "cockatiel": true } }, diff --git a/lavamoat/browserify/mmi/policy.json b/lavamoat/browserify/mmi/policy.json index 632961531ab0..d775d60636eb 100644 --- a/lavamoat/browserify/mmi/policy.json +++ b/lavamoat/browserify/mmi/policy.json @@ -2476,12 +2476,8 @@ } }, "@metamask/remote-feature-flag-controller": { - "globals": { - "console.error": true - }, "packages": { "@metamask/base-controller": true, - "@metamask/utils": true, "cockatiel": true } }, diff --git a/package.json b/package.json index b705cd324caa..a9fdfe85eea0 100644 --- a/package.json +++ b/package.json @@ -336,7 +336,7 @@ "@metamask/providers": "^18.2.0", "@metamask/queued-request-controller": "^7.0.1", "@metamask/rate-limit-controller": "^6.0.0", - "@metamask/remote-feature-flag-controller": "file:../core/packages/remote-feature-flag-controller", + "@metamask/remote-feature-flag-controller": "^1.0.0", "@metamask/rpc-errors": "^7.0.0", "@metamask/safe-event-emitter": "^3.1.1", "@metamask/scure-bip39": "^2.0.3", diff --git a/ui/pages/settings/info-tab/info-tab.component.js b/ui/pages/settings/info-tab/info-tab.component.js index 0c5af3d6c38f..87001b1bb2d3 100644 --- a/ui/pages/settings/info-tab/info-tab.component.js +++ b/ui/pages/settings/info-tab/info-tab.component.js @@ -57,7 +57,7 @@ export default class InfoTab extends PureComponent { componentDidMount() { const { t } = this.context; handleSettingsRefs(t, t('about'), this.settingsRefs); - if (this.props.remoteFeatureFlags.length > 0) { + if (!this.props.remoteFeatureFlags.testBooleanFlag) { // eslint-disable-next-line no-console console.log( 'Feature flag fetched successfully', diff --git a/yarn.lock b/yarn.lock index 09c8fa4ed408..45d8eda71889 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6299,14 +6299,14 @@ __metadata: languageName: node linkType: hard -"@metamask/remote-feature-flag-controller@file:../core/packages/remote-feature-flag-controller::locator=metamask-crx%40workspace%3A.": - version: 0.0.0 - resolution: "@metamask/remote-feature-flag-controller@file:../core/packages/remote-feature-flag-controller#../core/packages/remote-feature-flag-controller::hash=b9c79c&locator=metamask-crx%40workspace%3A." +"@metamask/remote-feature-flag-controller@npm:^1.0.0": + version: 1.0.0 + resolution: "@metamask/remote-feature-flag-controller@npm:1.0.0" dependencies: "@metamask/base-controller": "npm:^7.0.2" "@metamask/utils": "npm:^10.0.0" cockatiel: "npm:^3.1.2" - checksum: 10/ca6c43b375dcc1cc2a53a8d3bbbbfabed622b43ec85fe3958f0ffff60935f0f02cea9ed3f23c3f985cfd4515c9b4c8c5a4e1210ef2208ffda867bf8f1d9d3c08 + checksum: 10/2e66724b6c0387210d106ede0128f934f6175b3656e1cc7734341dd443c3423c6a6cf9a4ca0d84ff5ea89897af6f3068b4f262a8ab9db647524f00f7d6bb4ed4 languageName: node linkType: hard @@ -26792,7 +26792,7 @@ __metadata: "@metamask/providers": "npm:^18.2.0" "@metamask/queued-request-controller": "npm:^7.0.1" "@metamask/rate-limit-controller": "npm:^6.0.0" - "@metamask/remote-feature-flag-controller": "file:../core/packages/remote-feature-flag-controller" + "@metamask/remote-feature-flag-controller": "npm:^1.0.0" "@metamask/rpc-errors": "npm:^7.0.0" "@metamask/safe-event-emitter": "npm:^3.1.1" "@metamask/scure-bip39": "npm:^2.0.3"