| 114 | } |
| 115 | memoryCache.delete(key); |
| 116 | foregroundLoads.delete(key); |
| 117 | backgroundLoads.delete(key); |
| 118 | return enqueueCacheWrite(key, async () => { |
| 119 | if (requestEpoch !== cacheEpoch || version < (latestRequestVersions.get(key) ?? 0)) { |
| 120 | return false; |
| 121 | } |
| 122 | await localforage.removeItem(key); |
| 123 | return true; |
| 124 | }); |
| 125 | } |
| 126 | |
| 127 | export async function clearDataCache() { |
| 128 | const theme = await localforage.getItem("theme"); |
| 129 | cacheEpoch += 1; |
| 130 | await Promise.allSettled([...writeQueues.values()]); |
| 131 | memoryCache.clear(); |
| 132 | latestRequestVersions.clear(); |
| 133 | foregroundRequests.clear(); |
| 134 | foregroundLoads.clear(); |
| 135 | backgroundLoads.clear(); |