Skip to content

Commit 5d56b8a

Browse files
authored
fix(MetaService): Address a caching issue (#105)
Address an issue where fetching a viewlayout would reduce the contents of the cache Update github workflow cache to v4
1 parent 230ef77 commit 5d56b8a

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

.github/workflows/main.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
- uses: actions/checkout@v1
1212

1313
- name: Cache node modules
14-
uses: actions/cache@v1
14+
uses: actions/cache@v4
1515
with:
1616
path: ~/.npm
1717
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}

src/services/MetaService.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,16 +240,23 @@ export class MetaService {
240240
if (result && result.sectionHeaders) {
241241
this.sectionHeaders = result.sectionHeaders;
242242
}
243-
result.fields = keepFieldsFromLayout ? result.fields : this.fields;
244243
result.layouts = this.layouts;
245244
result.trackTrigger = this.trackTrigger;
246245
result.tracks = this.tracks;
247246
result.sectionHeaders = this.sectionHeaders;
248247

249248
result.allFieldsLoaded = result.allFieldsLoaded || this.allFieldsLoaded;
250249
this.allFieldsLoaded = result.allFieldsLoaded;
251-
// tslint:disable-next-line:no-floating-promises
252-
Cache.put(this.endpoint, result);
250+
if (keepFieldsFromLayout) {
251+
// Save cache as separate object
252+
const cacheResult = { ...result, fields: this.fields };
253+
// tslint:disable-next-line:no-floating-promises
254+
Cache.put(this.endpoint, cacheResult);
255+
} else {
256+
result.fields = this.fields;
257+
// tslint:disable-next-line:no-floating-promises
258+
Cache.put(this.endpoint, result);
259+
}
253260
}
254261

255262
private missing(fields): string[] {

0 commit comments

Comments
 (0)