refactor: use centralized DATABASE_CONFIG for all store names in service.ts and wallet-setup.ts
This commit is contained in:
parent
09b34f7e07
commit
42f6e9ed05
@ -226,9 +226,9 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||
console.log('🔄 IndexedDB upgrade needed, checking wallet store...');
|
||||
|
||||
// Créer le store wallet seulement s'il n'existe pas
|
||||
if (!db.objectStoreNames.contains('wallet')) {
|
||||
const store = db.createObjectStore('wallet', { keyPath: 'pre_id' });
|
||||
console.log('✅ Wallet store created with keyPath: pre_id');
|
||||
if (!db.objectStoreNames.contains(DATABASE_CONFIG.stores.wallet.name)) {
|
||||
const store = db.createObjectStore(DATABASE_CONFIG.stores.wallet.name, { keyPath: DATABASE_CONFIG.stores.wallet.keyPath as string });
|
||||
console.log(`✅ Wallet store created with keyPath: ${DATABASE_CONFIG.stores.wallet.keyPath}`);
|
||||
} else {
|
||||
console.log('✅ Wallet store already exists');
|
||||
}
|
||||
|
||||
@ -24,6 +24,7 @@ import Database from './database.service';
|
||||
import { storeData, retrieveData } from './storage.service';
|
||||
// import { testData } from './storage.service'; // Unused import
|
||||
import { BackUp } from '../models/backup.model';
|
||||
import { DATABASE_CONFIG } from './database-config';
|
||||
|
||||
export const U32_MAX = 4294967295;
|
||||
|
||||
@ -1160,11 +1161,11 @@ export default class Services {
|
||||
|
||||
// Clear all stores
|
||||
const db = await Database.getInstance();
|
||||
await db.clearStore('wallet');
|
||||
await db.clearStore('shared_secrets');
|
||||
await db.clearStore('unconfirmed_secrets');
|
||||
await db.clearStore('processes');
|
||||
await db.clearStore('diffs');
|
||||
await db.clearStore(DATABASE_CONFIG.stores.wallet.name);
|
||||
await db.clearStore(DATABASE_CONFIG.stores.shared_secrets.name);
|
||||
await db.clearStore(DATABASE_CONFIG.stores.unconfirmed_secrets.name);
|
||||
await db.clearStore(DATABASE_CONFIG.stores.processes.name);
|
||||
await db.clearStore(DATABASE_CONFIG.stores.diffs.name);
|
||||
}
|
||||
|
||||
sendNewTxMessage(message: string) {
|
||||
@ -1811,7 +1812,7 @@ export default class Services {
|
||||
|
||||
async saveDeviceInDatabase(device: Device): Promise<void> {
|
||||
const db = await Database.getInstance();
|
||||
const walletStore = 'wallet';
|
||||
const walletStore = DATABASE_CONFIG.stores.wallet.name;
|
||||
try {
|
||||
const prevDevice = await this.getDeviceFromDatabase();
|
||||
if (prevDevice) {
|
||||
@ -1829,7 +1830,7 @@ export default class Services {
|
||||
|
||||
async getDeviceFromDatabase(): Promise<Device | null> {
|
||||
const db = await Database.getInstance();
|
||||
const walletStore = 'wallet';
|
||||
const walletStore = DATABASE_CONFIG.stores.wallet.name;
|
||||
try {
|
||||
const dbRes = await db.getObject(walletStore, '1');
|
||||
if (!dbRes) {
|
||||
@ -1895,13 +1896,13 @@ export default class Services {
|
||||
const db = await Database.getInstance();
|
||||
try {
|
||||
// Clear all stores
|
||||
await db.clearStore('wallet');
|
||||
await db.clearStore('processes');
|
||||
await db.clearStore('shared_secrets');
|
||||
await db.clearStore('unconfirmed_secrets');
|
||||
await db.clearStore('diffs');
|
||||
await db.clearStore('data');
|
||||
await db.clearStore('labels');
|
||||
await db.clearStore(DATABASE_CONFIG.stores.wallet.name);
|
||||
await db.clearStore(DATABASE_CONFIG.stores.processes.name);
|
||||
await db.clearStore(DATABASE_CONFIG.stores.shared_secrets.name);
|
||||
await db.clearStore(DATABASE_CONFIG.stores.unconfirmed_secrets.name);
|
||||
await db.clearStore(DATABASE_CONFIG.stores.diffs.name);
|
||||
await db.clearStore(DATABASE_CONFIG.stores.data.name);
|
||||
await db.clearStore(DATABASE_CONFIG.stores.labels.name);
|
||||
|
||||
// Clear localStorage
|
||||
localStorage.clear();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user