Skip to content

Commit

Permalink
Only reset store when intl fields exist
Browse files Browse the repository at this point in the history
  • Loading branch information
SachaG committed Jun 13, 2018
1 parent 587df75 commit b0e7c4b
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/vulcan-core/lib/modules/components/App.jsx
Original file line number Diff line number Diff line change
@@ -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() {
7 changes: 7 additions & 0 deletions packages/vulcan-lib/lib/modules/collections.js
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit b0e7c4b

Please sign in to comment.