mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-28 08:22:24 +00:00
Refactor `js/storage/dmDb.js` to use a singleton connection pattern for IndexedDB. Previously, the database was opened and closed for every single operation, leading to significant overhead. Changes: - Introduced `dbInstance` and `dbPromise` to cache the database connection. - Refactored `openDmDb` to reuse the existing connection or pending promise. - Added `onversionchange` handler to safely close the connection if an upgrade is requested. - Removed all manual `db.close()` calls from exported functions. - Added a benchmark script in `tests/benchmark-dm-db.mjs` to verify the improvement. Co-authored-by: PR0M3TH3AN <[email protected]>