Skip to content

Commit d1d863e

Browse files
committed
made early indexes variables update when changed
1 parent 89d3463 commit d1d863e

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

packages/compass-preferences-model/src/compass-web-preferences-access.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ const editablePreferences: (keyof UserPreferences)[] = [
1313
'enableGenAISampleDocumentPassingOnAtlasProject',
1414
'enableGenAIFeaturesAtlasOrg',
1515
'enableGenAIFeaturesAtlasProject',
16+
17+
// Value can change from false to true during allocation / checking
18+
'enableIndexesGuidanceExp',
19+
'showIndexesGuidanceVariant',
1620
];
1721

1822
export class CompassWebPreferencesAccess implements PreferencesAccess {
@@ -27,9 +31,9 @@ export class CompassWebPreferencesAccess implements PreferencesAccess {
2731
savePreferences(_attributes: Partial<UserPreferences>) {
2832
// Only allow runtime updating certain preferences.
2933
if (
30-
Object.keys(_attributes).length === 1 &&
31-
editablePreferences.includes(
32-
Object.keys(_attributes)[0] as keyof UserPreferences
34+
Object.keys(_attributes).length >= 1 &&
35+
Object.keys(_attributes).every((attribute) =>
36+
editablePreferences.includes(attribute as keyof UserPreferences)
3337
)
3438
) {
3539
return Promise.resolve(this._preferences.savePreferences(_attributes));

packages/compass-web/src/entrypoint.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,9 +273,7 @@ const CompassWeb = ({
273273
onLog,
274274
onDebug,
275275
});
276-
277276
const preferencesAccess = useCompassWebPreferences(initialPreferences);
278-
279277
const initialWorkspaceRef = useRef(initialWorkspace);
280278
const initialWorkspaceTabsRef = useRef(
281279
initialWorkspaceRef.current ? [initialWorkspaceRef.current] : []
@@ -296,6 +294,21 @@ const CompassWeb = ({
296294
preferences: preferencesAccess.current,
297295
});
298296

297+
useEffect(() => {
298+
const updateEarlyIndexesPreferences = async () => {
299+
await preferencesAccess.current.savePreferences({
300+
enableIndexesGuidanceExp: initialPreferences?.enableIndexesGuidanceExp,
301+
showIndexesGuidanceVariant:
302+
initialPreferences?.showIndexesGuidanceVariant,
303+
});
304+
};
305+
void updateEarlyIndexesPreferences();
306+
}, [
307+
initialPreferences?.enableIndexesGuidanceExp,
308+
initialPreferences?.showIndexesGuidanceVariant,
309+
preferencesAccess,
310+
]);
311+
299312
return (
300313
<GlobalAppRegistryProvider value={appRegistry.current}>
301314
<AppRegistryProvider scopeName="Compass Web Root">

0 commit comments

Comments
 (0)