@selfcommunity/react-ui 0.9.0-alpha.12 → 0.9.0-alpha.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -108,11 +108,24 @@ function NavigationSettingsIconButton(inProps) {
108
108
  window.open(platformUrl, '_blank').focus();
109
109
  });
110
110
  };
111
+ /**
112
+ * Handles preferences update
113
+ */
114
+ const handlePreferencesUpdate = () => {
115
+ api_services_1.PreferenceService.getAllPreferences().then((preferences) => {
116
+ const prefs = preferences['results'].reduce((obj, p) => (Object.assign(Object.assign({}, obj), { [`${p.section}.${p.name}`]: p })), {});
117
+ scPreferences.setPreferences(prefs);
118
+ });
119
+ };
111
120
  /**
112
121
  * Updates onBoarding dynamic preference
113
122
  */
114
123
  const showOnBoarding = () => {
115
- api_services_1.PreferenceService.updatePreferences({ [`${types_1.SCPreferenceName.ONBOARDING_HIDDEN}`]: false }).catch((e) => {
124
+ api_services_1.PreferenceService.updatePreferences({ [`${types_1.SCPreferenceName.ONBOARDING_HIDDEN}`]: false })
125
+ .then(() => {
126
+ handlePreferencesUpdate();
127
+ })
128
+ .catch((e) => {
116
129
  utils_1.Logger.error(Errors_1.SCOPE_SC_UI, e);
117
130
  });
118
131
  };
@@ -106,11 +106,24 @@ export default function NavigationSettingsIconButton(inProps) {
106
106
  window.open(platformUrl, '_blank').focus();
107
107
  });
108
108
  };
109
+ /**
110
+ * Handles preferences update
111
+ */
112
+ const handlePreferencesUpdate = () => {
113
+ PreferenceService.getAllPreferences().then((preferences) => {
114
+ const prefs = preferences['results'].reduce((obj, p) => (Object.assign(Object.assign({}, obj), { [`${p.section}.${p.name}`]: p })), {});
115
+ scPreferences.setPreferences(prefs);
116
+ });
117
+ };
109
118
  /**
110
119
  * Updates onBoarding dynamic preference
111
120
  */
112
121
  const showOnBoarding = () => {
113
- PreferenceService.updatePreferences({ [`${SCPreferenceName.ONBOARDING_HIDDEN}`]: false }).catch((e) => {
122
+ PreferenceService.updatePreferences({ [`${SCPreferenceName.ONBOARDING_HIDDEN}`]: false })
123
+ .then(() => {
124
+ handlePreferencesUpdate();
125
+ })
126
+ .catch((e) => {
114
127
  Logger.error(SCOPE_SC_UI, e);
115
128
  });
116
129
  };