Skip to content

Commit

Permalink
Revert changes to use_kibana_ui_setting
Browse files Browse the repository at this point in the history
  • Loading branch information
patrykkopycinski committed Nov 17, 2019
1 parent 4c33f2a commit 1b68662
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,22 @@ export const useKibanaUiSetting = (key: string, defaultValue?: GenericValue) =>
const core = useKibanaCore();
const uiSettingsClient = core.uiSettings;
const uiInjectedMetadata = core.injectedMetadata;
const uiSetting$ = useMemo(() => uiSettingsClient.get$(key, defaultValue), [uiSettingsClient]);
const uiSetting = useObservable(uiSetting$);
const setUiSetting = useCallback((value: GenericValue) => uiSettingsClient.set(key, value), [
uiSettingsClient,
]);
const defaultTimezoneProvider = useMemo(() => timezoneProvider(uiSettingsClient)(), [
uiSettingsClient,
]);

if (key === DEFAULT_KBN_VERSION) {
return [uiInjectedMetadata.getKibanaVersion()];
}

/* eslint-disable react-hooks/rules-of-hooks */
if (key === DEFAULT_TIMEZONE_BROWSER) {
return [defaultTimezoneProvider];
return [useMemo(() => timezoneProvider(uiSettingsClient)(), [uiSettingsClient])];
}

const uiSetting$ = useMemo(() => uiSettingsClient.get$(key, defaultValue), [uiSettingsClient]);
const uiSetting = useObservable(uiSetting$);
const setUiSetting = useCallback((value: GenericValue) => uiSettingsClient.set(key, value), [
uiSettingsClient,
]);
/* eslint-enable react-hooks/rules-of-hooks */

return [uiSetting, setUiSetting];
};

0 comments on commit 1b68662

Please sign in to comment.