Skip to content

Commit

Permalink
refactor: simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
tdeekens committed Jan 22, 2021
1 parent bf19ac7 commit cbe4626
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,10 @@ const parseFlags = (fetchedFlags: TFetchedFlags): TParsedHttpAdapterFlags =>
])
);

type TAdditionalEnvironmentProperties = {
env: {
enableFeatureConfigurationFetching?: boolean;
}
};
export const SetupFlopFlipProvider = (props: Props) => {
const apolloClient = useApolloClient();
const enableFeatureConfigurationFetching = useApplicationContext<TAdditionalEnvironmentProperties>(
(context) => context.environment.env.enableFeatureConfigurationFetching
const enableFeatureConfigurationFetching = useApplicationContext(
(context) => context.environment.enableFeatureConfigurationFetching
);
const allMenuFeatureToggles = useAllMenuFeatureToggles();
const flags = React.useMemo(
Expand All @@ -101,11 +96,11 @@ export const SetupFlopFlipProvider = (props: Props) => {
[allMenuFeatureToggles.allFeatureToggles, props.flags]
);
React.useMemo(() => {
combineAdapters.combine(
[ldAdapter, enableFeatureConfigurationFetching && httpAdapter].filter(
Boolean
)
);
if (enableFeatureConfigurationFetching) {
combineAdapters.combine([ldAdapter, httpAdapter]);
} else {
combineAdapters.combine([ldAdapter]);
}
}, [enableFeatureConfigurationFetching]);

const defaultFlags = React.useMemo(
Expand Down
1 change: 1 addition & 0 deletions packages/constants/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,5 +169,6 @@ export interface ApplicationWindow extends Window {
useFullRedirectsForLinks?: boolean;
// Properties for OIDC-like workflow for development
__DEVELOPMENT__?: ApplicationOidcForDevelopmentConfig;
enableFeatureConfigurationFetching?: boolean;
};
}
42 changes: 6 additions & 36 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8542,7 +8542,7 @@ ansi-regex@^3.0.0:
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-3.0.0.tgz#ed0317c322064f79466c02966bddb605ab37d998"
integrity sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=

ansi-regex@^4.0.0, ansi-regex@^4.1.0:
ansi-regex@^4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-4.1.0.tgz#8b9f8f08cf1acb843756a839ca8c7e3168c51997"
integrity sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==
Expand Down Expand Up @@ -15098,7 +15098,7 @@ gatsby-legacy-polyfills@^0.5.0:
dependencies:
core-js-compat "^3.6.5"

gatsby-link@^2.9.0:
gatsby-link@2.9.0, gatsby-link@^2.9.0:
version "2.9.0"
resolved "https://registry.yarnpkg.com/gatsby-link/-/gatsby-link-2.9.0.tgz#8507653835503f554426d054ab0007174d0b6030"
integrity sha512-MT1qAVYhkWPaTSAizVABVMt6WuSv7O8b0YZSbGIUx4vRKIq3DcbjY1Kikf2RrysXDa3/p3c+E5fUMiy8h5lfuQ==
Expand Down Expand Up @@ -16359,23 +16359,13 @@ graphql-ws@4.1.0:
resolved "https://registry.yarnpkg.com/graphql-ws/-/graphql-ws-4.1.0.tgz#cebe281474b5501d7be66210fb5711633b27fd78"
integrity sha512-DxJP1y2YzCqVLy7DrQN0iuR2l48vMOBWukX2d/J9aN2o5x9un5psIIq/2UFRh91UGARmfvPH86y1p4qbC1dITg==

graphql@14.7.0, graphql@^14.6.0:
graphql@14.7.0, graphql@15.3.0, graphql@^14.6.0, graphql@^15.4.0:
version "14.7.0"
resolved "https://registry.yarnpkg.com/graphql/-/graphql-14.7.0.tgz#7fa79a80a69be4a31c27dda824dc04dac2035a72"
integrity sha512-l0xWZpoPKpppFzMfvVyFmp9vLN7w/ZZJPefUicMCepfJeQ8sMcztloGYY9DfjVPo6tIUDzU5Hw3MUbIjj9AVVA==
dependencies:
iterall "^1.2.2"

graphql@15.3.0:
version "15.3.0"
resolved "https://registry.yarnpkg.com/graphql/-/graphql-15.3.0.tgz#3ad2b0caab0d110e3be4a5a9b2aa281e362b5278"
integrity sha512-GTCJtzJmkFLWRfFJuoo9RWWa/FfamUHgiFosxi/X1Ani4AVWbeyBenZTNX6dM+7WSbbFfTo/25eh0LLkwHMw2w==

graphql@^15.4.0:
version "15.4.0"
resolved "https://registry.yarnpkg.com/graphql/-/graphql-15.4.0.tgz#e459dea1150da5a106486ba7276518b5295a4347"
integrity sha512-EB3zgGchcabbsU9cFe1j+yxdzKQKAbGUWRb13DsrsMN1yyfmmIq+2+L5MqVWcDCE4V89R5AyUOi7sMOGxdsYtA==

gray-matter@^4.0.2:
version "4.0.2"
resolved "https://registry.yarnpkg.com/gray-matter/-/gray-matter-4.0.2.tgz#9aa379e3acaf421193fce7d2a28cebd4518ac454"
Expand Down Expand Up @@ -24299,27 +24289,7 @@ pretty-error@^2.1.1:
lodash "^4.17.20"
renderkid "^2.0.4"

pretty-format@^24.9.0:
version "24.9.0"
resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-24.9.0.tgz#12fac31b37019a4eea3c11aa9a959eb7628aa7c9"
integrity sha512-00ZMZUiHaJrNfk33guavqgvfJS30sLYf0f8+Srklv0AMPodGGHcoHgksZ3OThYnIvOd+8yMCn0YiEOogjlgsnA==
dependencies:
"@jest/types" "^24.9.0"
ansi-regex "^4.0.0"
ansi-styles "^3.2.0"
react-is "^16.8.4"

pretty-format@^25.5.0:
version "25.5.0"
resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-25.5.0.tgz#7873c1d774f682c34b8d48b6743a2bf2ac55791a"
integrity sha512-kbo/kq2LQ/A/is0PQwsEHM7Ca6//bGPPvU6UnsdDRSKTWxT/ru/xb88v4BJf6a69H+uTytOEsTusT9ksd/1iWQ==
dependencies:
"@jest/types" "^25.5.0"
ansi-regex "^5.0.0"
ansi-styles "^4.0.0"
react-is "^16.12.0"

pretty-format@^26.0.0, pretty-format@^26.6.2:
pretty-format@26.6.2, pretty-format@^24.9.0, pretty-format@^25.5.0, pretty-format@^26.0.0, pretty-format@^26.6.2:
version "26.6.2"
resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-26.6.2.tgz#e35c2705f14cb7fe2fe94fa078345b444120fc93"
integrity sha512-7AeGuCYNGmycyQbCqd/3PWH4eOoX/OiCa0uphp57NVTeAGdJGaAliecxwBDHYQCIvrW7aDBZCYeNTP/WX69mkg==
Expand Down Expand Up @@ -25054,7 +25024,7 @@ react-intl@5.10.16, react-intl@^5.7.0:
shallow-equal "^1.2.1"
tslib "^2.0.1"

react-is@16.13.1, react-is@^16.12.0, react-is@^16.13.1, react-is@^16.6.0, react-is@^16.7.0, react-is@^16.8.1, react-is@^16.8.4, react-is@^16.8.6:
react-is@16.13.1, react-is@^16.12.0, react-is@^16.13.1, react-is@^16.6.0, react-is@^16.7.0, react-is@^16.8.1, react-is@^16.8.6:
version "16.13.1"
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4"
integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==
Expand Down Expand Up @@ -26715,7 +26685,7 @@ shallowequal@^1.1.0:
resolved "https://registry.yarnpkg.com/shallowequal/-/shallowequal-1.1.0.tgz#188d521de95b9087404fd4dcb68b13df0ae4e7f8"
integrity sha512-y0m1JoUZSlPAjXVtPPW70aZWfIL/dSP7AFkRnniLCrK/8MDKog3TySTBmckD+RObVxH0v4Tox67+F14PdED2oQ==

sharp@^0.27.0:
sharp@0.27.0, sharp@^0.27.0:
version "0.27.0"
resolved "https://registry.yarnpkg.com/sharp/-/sharp-0.27.0.tgz#523fba913ba674985dcc688a6a5237384079d80f"
integrity sha512-II+YBCW3JuVWQZdpTEA2IBjJcYXPuoKo3AUqYuW+FK9Um93v2gPE2ihICCsN5nHTUoP8WCjqA83c096e8n//Rw==
Expand Down

0 comments on commit cbe4626

Please sign in to comment.