Only reset store when intl fields exist

This commit is contained in:
SachaG 2018-06-14 08:47:58 +09:00
parent 587df75021
commit b0e7c4bf97
2 changed files with 11 additions and 2 deletions

View file

@ -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() {

View file

@ -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;