mirror of
https://github.com/outline/outline.git
synced 2026-01-06 11:09:55 -06:00
fix: Clear IndexedDB cache command on FF, closes #6821
This commit is contained in:
@@ -1,10 +1,33 @@
|
||||
// A function to delete all IndexedDB databases
|
||||
export async function deleteAllDatabases() {
|
||||
const databases = await window.indexedDB.databases();
|
||||
import flatten from "lodash/flatten";
|
||||
import stores from "~/stores";
|
||||
import { flattenTree } from "./tree";
|
||||
|
||||
for (const database of databases) {
|
||||
if (database.name) {
|
||||
window.indexedDB.deleteDatabase(database.name);
|
||||
/**
|
||||
* Delete all databases in the browser.
|
||||
*
|
||||
* @returns A promise that resolves when all databases have been deleted.
|
||||
*/
|
||||
export async function deleteAllDatabases() {
|
||||
if ("databases" in window.indexedDB) {
|
||||
const databases = await window.indexedDB.databases();
|
||||
|
||||
for (const database of databases) {
|
||||
if (database.name) {
|
||||
window.indexedDB.deleteDatabase(database.name);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// If the browser does not support listing databases, we need to manually delete as best we can
|
||||
// by iterating over all known collections and documents.
|
||||
await Promise.all(
|
||||
stores.collections.orderedData.map(async (collection) => {
|
||||
const nodes = flatten(collection.documents?.map(flattenTree));
|
||||
|
||||
return nodes.map(async (node) => {
|
||||
window.indexedDB.deleteDatabase(`document.${node.id}`);
|
||||
});
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user