diff --git a/.changeset/violet-pets-attend.md b/.changeset/violet-pets-attend.md new file mode 100644 index 000000000000..f93079c94fa4 --- /dev/null +++ b/.changeset/violet-pets-attend.md @@ -0,0 +1,6 @@ +--- +'@rocket.chat/ui-client': patch +'@rocket.chat/meteor': patch +--- + +Fixed the data structure of the features preview diff --git a/apps/meteor/client/views/account/featurePreview/AccountFeaturePreviewPage.tsx b/apps/meteor/client/views/account/featurePreview/AccountFeaturePreviewPage.tsx index 358d2394003b..cafb8bf6cfaf 100644 --- a/apps/meteor/client/views/account/featurePreview/AccountFeaturePreviewPage.tsx +++ b/apps/meteor/client/views/account/featurePreview/AccountFeaturePreviewPage.tsx @@ -56,8 +56,9 @@ const AccountFeaturePreviewPage = () => { const { featuresPreview } = watch(); const handleSave = async () => { + const featuresToBeSaved = featuresPreview.map((feature) => ({ name: feature.name, value: feature.value })); try { - await setUserPreferences({ data: { featuresPreview } }); + await setUserPreferences({ data: { featuresPreview: featuresToBeSaved } }); dispatchToastMessage({ type: 'success', message: t('Preferences_saved') }); } catch (error) { dispatchToastMessage({ type: 'error', message: error }); diff --git a/packages/ui-client/src/hooks/useFeaturePreviewList.ts b/packages/ui-client/src/hooks/useFeaturePreviewList.ts index 08bda4ff81ff..986307ce07cb 100644 --- a/packages/ui-client/src/hooks/useFeaturePreviewList.ts +++ b/packages/ui-client/src/hooks/useFeaturePreviewList.ts @@ -97,14 +97,20 @@ export const parseSetting = (setting?: FeaturePreviewProps[] | string) => { return setting; }; -export const useFeaturePreviewList = (featuresList: Pick[]) => { +export const useFeaturePreviewList = (featuresList: FeaturePreviewProps[]) => { const unseenFeatures = enabledDefaultFeatures.filter( (defaultFeature) => !featuresList?.find((feature) => feature.name === defaultFeature.name), ).length; const mergedFeatures = enabledDefaultFeatures.map((defaultFeature) => { - const features = featuresList?.find((feature) => feature.name === defaultFeature.name); - return { ...defaultFeature, ...features }; + const feature = featuresList?.find((feature) => feature.name === defaultFeature.name); + // overwrite enableQuery and disabled with default value to avoid a migration to remove this from the DB + // payload on save now only have `name` and `value` + if (feature) { + feature.enableQuery = defaultFeature.enableQuery; + feature.disabled = defaultFeature.disabled; + } + return { ...defaultFeature, ...feature }; }); return { unseenFeatures, features: mergedFeatures };