| 114 | } |
| 115 | |
| 116 | export async function clearDataCache() { |
| 117 | const theme = await localforage.getItem("theme"); |
| 118 | cacheEpoch += 1; |
| 119 | await Promise.allSettled([...writeQueues.values()]); |
| 120 | memoryCache.clear(); |
| 121 | latestRequestVersions.clear(); |
| 122 | foregroundRequests.clear(); |
| 123 | foregroundLoads.clear(); |
| 124 | backgroundLoads.clear(); |
| 125 | await localforage.clear(); |
| 126 | if (theme) { |
| 127 | await localforage.setItem("theme", theme); |
| 128 | } |
| 129 | if (typeof window !== "undefined") { |
| 130 | window.dispatchEvent(new Event(CACHE_CLEARED_EVENT)); |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | export function getCacheEpoch() { |
| 135 | return cacheEpoch; |