UNPKG

fastcomments-react-native-sdk

Version:

React Native FastComments Components. Add live commenting to any React Native application.

32 lines (31 loc) 1.45 kB
export function handleNewCustomConfig(state, customConfig, overwrite) { const config = state.config; if (customConfig) { for (const key in customConfig) { // for the customization page (css is sent from server, but newer version from client) // if the custom config has translations, merge them with what the client specified if (key === 'translations') { if (config[key].get()) { config[key].set(Object.assign({}, customConfig[key], config[key].get())); } else { config[key].set(customConfig[key]); } } else if ((config[key] === undefined || overwrite) || key === 'wrap' || key === 'hasDarkBackground') { // undefined is important here (test comment thread viewer w/ customizations like hideCommentsUnderCountTextFormat/useShowCommentsToggle // @ts-ignore config[key].set(customConfig[key]); } } if (!state.sortDirection.get()) { const defaultSortDirection = config.defaultSortDirection.get(); if (typeof defaultSortDirection === 'string') { state.sortDirection.set(defaultSortDirection); } } } const configTranslations = config.translations.get(); if (configTranslations) { state.translations.merge(configTranslations); } }