Skip to content

Commit

Permalink
fix: cauche custom forms in populate cache
Browse files Browse the repository at this point in the history
  • Loading branch information
joseph-mccombs committed Jan 28, 2021
1 parent 4431281 commit d79778c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
8 changes: 6 additions & 2 deletions modules/cached-resources/populate-cache.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { cacheAutofillData, cacheResidentData } from './read';
import { cacheAutofillData, cacheResidentData, customFormsQuery } from './read';
import { retrieveCurrentUserAsyncFunction } from '../../services/parse/auth';
import { storeData } from '../async-storage';

Expand All @@ -24,13 +24,17 @@ export default function populateCache(user) {
}
})
.then(() => {
// store ID forms
const queryParams = {
skip: 0,
offset: 0,
limit: 100000,
parseColumn: 'surveyingOrganization',
parseParam: user.get("organization"),
parseParam: user.get('organization'),
};
cacheResidentData(queryParams);
})
.then(() => {
customFormsQuery(user.get('organization'));
})
}
13 changes: 11 additions & 2 deletions modules/cached-resources/read.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,17 @@ function customFormsQuery(surveyingOrganization) {
checkOnlineStatus().then((online) => {
if (online) {
customQueryService(0, 5000, 'FormSpecificationsV2', 'organizations', surveyingOrganization).then(async (forms) => {
await storeData(forms, 'customForms');
resolve(JSON.parse(JSON.stringify(forms)));
if (forms !== null && forms !== undefined && forms !== '') {
await storeData(forms, 'customForms');
resolve(JSON.parse(JSON.stringify(forms)));
}
else {
getData('customForms').then((forms) => {
resolve(forms);
}, (error) => {
reject(error);
});
}
}, (error) => {
reject(error);
});
Expand Down

0 comments on commit d79778c

Please sign in to comment.