refactor: remove cold-path cache key preflight
This commit is contained in:
@@ -25,13 +25,6 @@ class CacheEnabledApiClient extends ApiClient {
|
||||
return axios.get(this.url);
|
||||
}
|
||||
|
||||
async getCacheKeyFromServer() {
|
||||
const response = await axios.get(
|
||||
`/api/v1/accounts/${this.accountIdFromRoute}/cache_keys`
|
||||
);
|
||||
return response.data.cache_keys?.[this.cacheModelName] ?? null;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line class-methods-use-this
|
||||
extractDataFromResponse(response) {
|
||||
return response.data.payload;
|
||||
@@ -63,16 +56,10 @@ class CacheEnabledApiClient extends ApiClient {
|
||||
return this.marshallData(localData);
|
||||
}
|
||||
|
||||
// Empty IDB (first load or wiped): capture the authoritative key before
|
||||
// persisting rows so future boots can revalidate this cached data.
|
||||
let serverKey = null;
|
||||
try {
|
||||
serverKey = await this.getCacheKeyFromServer();
|
||||
} catch {
|
||||
// Ignore error. The network fetch below should still work, and storing
|
||||
// null keeps this cache eligible for boot-time revalidation later.
|
||||
}
|
||||
return this.refetchAndCommit(serverKey);
|
||||
// Empty IDB (first load or wiped): fetch data without a cache key. The
|
||||
// next pushed key map won't match the missing key and will refetch once,
|
||||
// stamping the authoritative key — the client never pulls keys itself.
|
||||
return this.refetchAndCommit(null);
|
||||
}
|
||||
|
||||
async refetchAndCommit(newKey = null) {
|
||||
@@ -89,7 +76,7 @@ class CacheEnabledApiClient extends ApiClient {
|
||||
});
|
||||
|
||||
await this.dataManager.setCacheKeys({
|
||||
[this.cacheModelName]: newKey === undefined ? null : newKey,
|
||||
[this.cacheModelName]: newKey,
|
||||
});
|
||||
} catch {
|
||||
// Ignore error
|
||||
|
||||
Reference in New Issue
Block a user