[DEV-268] Fix long loading time in homepage (#1206)

This commit is contained in:
Joel Elias Méndez 2022-05-30 16:04:32 -03:00 committed by GitHub
parent d3b47eaa73
commit b620baf5ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 7 deletions

View File

@ -5,6 +5,7 @@ import classNames from 'classnames';
import i18n from 'lib-app/i18n'; import i18n from 'lib-app/i18n';
import API from 'lib-app/api-call'; import API from 'lib-app/api-call';
import history from 'lib-app/history'; import history from 'lib-app/history';
import SessionStore from 'lib-app/session-store';
import Captcha from 'app/main/captcha'; import Captcha from 'app/main/captcha';
import SubmitButton from 'core-components/submit-button'; import SubmitButton from 'core-components/submit-button';
@ -33,11 +34,22 @@ class MainSignUpWidget extends React.Component {
} }
componentDidMount() { componentDidMount() {
if(!SessionStore.getItem('customFields')) {
API.call({ API.call({
path: '/system/get-custom-fields', path: '/system/get-custom-fields',
data: {} data: {}
}) })
.then(result => this.setState({customFields: result.data})); .then(result => {
SessionStore.storeCustomField(result.data);
this.setState({
customFields: result.data
});
})
} else {
this.setState({
customFields: SessionStore.getCustomFields()
});
}
} }
render() { render() {

View File

@ -48,6 +48,10 @@ class SessionStore {
return JSON.parse(this.getItem('departments')); return JSON.parse(this.getItem('departments'));
} }
getCustomFields() {
return JSON.parse(this.getItem('customFields'));
}
storeRememberData({token, userId, expiration, isStaff}) { storeRememberData({token, userId, expiration, isStaff}) {
this.setItem('rememberData-token', token); this.setItem('rememberData-token', token);
this.setItem('rememberData-userId', userId); this.setItem('rememberData-userId', userId);
@ -55,6 +59,10 @@ class SessionStore {
this.setItem('rememberData-expiration', expiration); this.setItem('rememberData-expiration', expiration);
} }
storeCustomField(customFields) {
this.setItem('customFields', JSON.stringify(customFields));
}
storeConfigs(configs) { storeConfigs(configs) {
this.setItem('session-prefix', configs['session-prefix']); this.setItem('session-prefix', configs['session-prefix']);
this.setItem('language', configs.language); this.setItem('language', configs.language);
@ -70,8 +78,6 @@ class SessionStore {
this.setItem('maintenance-mode', configs['maintenance-mode']); this.setItem('maintenance-mode', configs['maintenance-mode']);
this.setItem('max-size', configs['max-size']); this.setItem('max-size', configs['max-size']);
this.setItem('tags', JSON.stringify(configs['tags'])); this.setItem('tags', JSON.stringify(configs['tags']));
this.setItem('max-size', configs['max-size']);
this.setItem('tags', JSON.stringify(configs['tags']));
this.setItem('default-is-locked', configs['default-is-locked']); this.setItem('default-is-locked', configs['default-is-locked']);
this.setItem('default-department-id', configs['default-department-id']); this.setItem('default-department-id', configs['default-department-id']);
} }