diff --git a/packages/vulcan-core/lib/modules/components/App.jsx b/packages/vulcan-core/lib/modules/components/App.jsx index e335b63084..b4f79e68c0 100644 --- a/packages/vulcan-core/lib/modules/components/App.jsx +++ b/packages/vulcan-core/lib/modules/components/App.jsx @@ -1,4 +1,4 @@ -import { Components, registerComponent, getSetting, Strings, runCallbacks, detectLocale } from 'meteor/vulcan:lib'; +import { Components, registerComponent, getSetting, Strings, runCallbacks, detectLocale, hasIntlFields } from 'meteor/vulcan:lib'; import React, { PureComponent } from 'react'; import PropTypes from 'prop-types'; import { IntlProvider, intlShape } from 'meteor/vulcan:i18n'; @@ -54,7 +54,9 @@ class App extends PureComponent { await this.props.editMutation({ documentId: this.props.currentUser._id, set: { locale }}); } moment.locale(locale); - this.props.client.resetStore() + if (hasIntlFields) { + this.props.client.resetStore(); + } }; getChildContext() { diff --git a/packages/vulcan-lib/lib/modules/collections.js b/packages/vulcan-lib/lib/modules/collections.js index a327ee1b6d..bc2f9bbe7d 100644 --- a/packages/vulcan-lib/lib/modules/collections.js +++ b/packages/vulcan-lib/lib/modules/collections.js @@ -11,6 +11,9 @@ const wrapAsync = (Meteor.wrapAsync)? Meteor.wrapAsync : Meteor._wrapAsync; registerSetting('maxDocumentsPerRequest', 1000, 'Maximum documents per request'); +// will be set to `true` if there is one or more intl schema fields +export let hasIntlFields = false; + export const Collections = []; export const getCollection = name => Collections.find(({ options: { collectionName }}) => name === collectionName); @@ -130,6 +133,10 @@ export const createCollection = options => { Object.keys(schema).forEach(fieldName => { const fieldSchema = schema[fieldName]; if (fieldSchema.type && fieldSchema.type.name === 'IntlString') { + + // we have at least one intl field + hasIntlFields = true; + // make non-intl field optional schema[fieldName].optional = true;