feat(core): cleanup unused indexeddb when bootstrapping (#11325)
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import '@affine/core/bootstrap/electron';
|
import '@affine/core/bootstrap/electron';
|
||||||
import '@affine/core/bootstrap/blocksuite';
|
import '@affine/core/bootstrap/blocksuite';
|
||||||
|
import '@affine/core/bootstrap/cleanup';
|
||||||
import '@affine/component/theme';
|
import '@affine/component/theme';
|
||||||
import './global.css';
|
import './global.css';
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
import '@affine/core/bootstrap/browser';
|
import '@affine/core/bootstrap/browser';
|
||||||
import '@affine/core/bootstrap/blocksuite';
|
import '@affine/core/bootstrap/blocksuite';
|
||||||
|
import '@affine/core/bootstrap/cleanup';
|
||||||
import './proxy';
|
import './proxy';
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import '@affine/core/bootstrap/browser';
|
import '@affine/core/bootstrap/browser';
|
||||||
import '@affine/core/bootstrap/blocksuite';
|
import '@affine/core/bootstrap/blocksuite';
|
||||||
|
import '@affine/core/bootstrap/cleanup';
|
||||||
import '@affine/component/theme';
|
import '@affine/component/theme';
|
||||||
import '@affine/core/mobile/styles/mobile.css';
|
import '@affine/core/mobile/styles/mobile.css';
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
import '@affine/core/bootstrap/browser';
|
import '@affine/core/bootstrap/browser';
|
||||||
import '@affine/core/bootstrap/blocksuite';
|
import '@affine/core/bootstrap/blocksuite';
|
||||||
|
import '@affine/core/bootstrap/cleanup';
|
||||||
import '@affine/component/theme';
|
import '@affine/component/theme';
|
||||||
|
|||||||
28
packages/frontend/core/src/bootstrap/cleanup.ts
Normal file
28
packages/frontend/core/src/bootstrap/cleanup.ts
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
function cleanupUnusedIndexedDB() {
|
||||||
|
const indexedDB = window.indexedDB;
|
||||||
|
if (!indexedDB) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
indexedDB.databases().then(databases => {
|
||||||
|
databases.forEach(database => {
|
||||||
|
if (database.name?.endsWith(':server-clock')) {
|
||||||
|
indexedDB.deleteDatabase(database.name);
|
||||||
|
}
|
||||||
|
if (database.name?.endsWith(':sync-metadata')) {
|
||||||
|
indexedDB.deleteDatabase(database.name);
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
database.name?.startsWith('idx:') &&
|
||||||
|
(database.name.endsWith(':block') || database.name.endsWith(':doc'))
|
||||||
|
) {
|
||||||
|
indexedDB.deleteDatabase(database.name);
|
||||||
|
}
|
||||||
|
if (database.name?.startsWith('jp:')) {
|
||||||
|
indexedDB.deleteDatabase(database.name);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
cleanupUnusedIndexedDB();
|
||||||
Reference in New Issue
Block a user