Skip to content

Commit

Permalink
function name change
Browse files Browse the repository at this point in the history
  • Loading branch information
ruchitharajaghatta committed Nov 4, 2024
1 parent db33a58 commit 8958931
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions packages/compass-preferences-model/src/preferences-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -473,10 +473,10 @@ export const storedUserPreferencesProps: Required<{
short: 'Enable AI Features',
long: 'Allow the use of AI features in Compass which make requests to 3rd party services.',
},
deriveValue: deriveValueFromOtherPreferences('enableGenAIFeatures', [
'enableGenAIFeaturesAtlasOrg',
'networkTraffic',
]),
deriveValue: deriveValueFromOtherPreferencesAsLogicalAnd(
'enableGenAIFeatures',
['enableGenAIFeaturesAtlasOrg', 'networkTraffic']
),
validator: z.boolean().default(true),
type: 'boolean',
},
Expand Down Expand Up @@ -1095,12 +1095,11 @@ function deriveNetworkTrafficOptionState<K extends keyof AllPreferences>(
}

/** Helper for deriving value/state for preferences from other preferences */
function deriveValueFromOtherPreferences<K extends keyof AllPreferences>(
property: K,
preferencesToDeriveFrom: K[]
): DeriveValueFunction<boolean> {
function deriveValueFromOtherPreferencesAsLogicalAnd<
K extends keyof AllPreferences
>(property: K, preferencesToDeriveFrom: K[]): DeriveValueFunction<boolean> {
return (v, s) => ({
value: v(property) && preferencesToDeriveFrom.every((p) => v(p)),
value: preferencesToDeriveFrom.every((p) => v(p)),
state:
s(property) ??
(preferencesToDeriveFrom.every((p) => v(p))
Expand Down

0 comments on commit 8958931

Please sign in to comment.