mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-02 03:57:52 +00:00
fix: idb is not available in firefox private mode [CW-2217] (#7524)
This commit is contained in:
@@ -18,6 +18,10 @@ class CacheEnabledApiClient extends ApiClient {
|
|||||||
return this.getFromCache();
|
return this.getFromCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return this.getFromNetwork();
|
||||||
|
}
|
||||||
|
|
||||||
|
getFromNetwork() {
|
||||||
return axios.get(this.url);
|
return axios.get(this.url);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,7 +36,12 @@ class CacheEnabledApiClient extends ApiClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getFromCache() {
|
async getFromCache() {
|
||||||
await this.dataManager.initDb();
|
try {
|
||||||
|
// IDB is not supported in Firefox private mode: https://bugzilla.mozilla.org/show_bug.cgi?id=781982
|
||||||
|
await this.dataManager.initDb();
|
||||||
|
} catch {
|
||||||
|
return this.getFromNetwork();
|
||||||
|
}
|
||||||
|
|
||||||
const { data } = await axios.get(
|
const { data } = await axios.get(
|
||||||
`/api/v1/accounts/${this.accountIdFromRoute}/cache_keys`
|
`/api/v1/accounts/${this.accountIdFromRoute}/cache_keys`
|
||||||
@@ -55,16 +64,22 @@ class CacheEnabledApiClient extends ApiClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async refetchAndCommit(newKey = null) {
|
async refetchAndCommit(newKey = null) {
|
||||||
await this.dataManager.initDb();
|
const response = await this.getFromNetwork();
|
||||||
const response = await axios.get(this.url);
|
|
||||||
this.dataManager.replace({
|
|
||||||
modelName: this.cacheModelName,
|
|
||||||
data: this.extractDataFromResponse(response),
|
|
||||||
});
|
|
||||||
|
|
||||||
await this.dataManager.setCacheKeys({
|
try {
|
||||||
[this.cacheModelName]: newKey,
|
await this.dataManager.initDb();
|
||||||
});
|
|
||||||
|
this.dataManager.replace({
|
||||||
|
modelName: this.cacheModelName,
|
||||||
|
data: this.extractDataFromResponse(response),
|
||||||
|
});
|
||||||
|
|
||||||
|
await this.dataManager.setCacheKeys({
|
||||||
|
[this.cacheModelName]: newKey,
|
||||||
|
});
|
||||||
|
} catch {
|
||||||
|
// Ignore error
|
||||||
|
}
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user