Skip to content

Commit b0e7c4b

Browse files
committed
Only reset store when intl fields exist
1 parent 587df75 commit b0e7c4b

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

packages/vulcan-core/lib/modules/components/App.jsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Components, registerComponent, getSetting, Strings, runCallbacks, detectLocale } from 'meteor/vulcan:lib';
1+
import { Components, registerComponent, getSetting, Strings, runCallbacks, detectLocale, hasIntlFields } from 'meteor/vulcan:lib';
22
import React, { PureComponent } from 'react';
33
import PropTypes from 'prop-types';
44
import { IntlProvider, intlShape } from 'meteor/vulcan:i18n';
@@ -54,7 +54,9 @@ class App extends PureComponent {
5454
await this.props.editMutation({ documentId: this.props.currentUser._id, set: { locale }});
5555
}
5656
moment.locale(locale);
57-
this.props.client.resetStore()
57+
if (hasIntlFields) {
58+
this.props.client.resetStore();
59+
}
5860
};
5961

6062
getChildContext() {

packages/vulcan-lib/lib/modules/collections.js

+7
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ const wrapAsync = (Meteor.wrapAsync)? Meteor.wrapAsync : Meteor._wrapAsync;
1111

1212
registerSetting('maxDocumentsPerRequest', 1000, 'Maximum documents per request');
1313

14+
// will be set to `true` if there is one or more intl schema fields
15+
export let hasIntlFields = false;
16+
1417
export const Collections = [];
1518

1619
export const getCollection = name => Collections.find(({ options: { collectionName }}) => name === collectionName);
@@ -130,6 +133,10 @@ export const createCollection = options => {
130133
Object.keys(schema).forEach(fieldName => {
131134
const fieldSchema = schema[fieldName];
132135
if (fieldSchema.type && fieldSchema.type.name === 'IntlString') {
136+
137+
// we have at least one intl field
138+
hasIntlFields = true;
139+
133140
// make non-intl field optional
134141
schema[fieldName].optional = true;
135142

0 commit comments

Comments
 (0)