forked from jsnbuchanan/crowd-funder-for-time-pwa
WIP: restore database migration system and improve error handling
- Restore runMigrations functionality for database schema migrations - Remove indexedDBMigrationService.ts (was for IndexedDB to SQLite migration) - Recreate migrationService.ts and db-sql/migration.ts for schema management - Add proper TypeScript error handling with type guards in AccountViewView - Fix CreateAndSubmitClaimResult property access in QuickActionBvcBeginView - Remove LeafletMouseEvent from Vue components array (it's a type, not component) - Add null check for UserNameDialog callback to prevent undefined assignment - Implement extractErrorMessage helper function for consistent error handling - Update router to remove database-migration route The migration system now properly handles database schema evolution across app versions, while the IndexedDB to SQLite migration service has been removed as it was specific to that one-time migration.
This commit is contained in:
@@ -167,8 +167,8 @@ import { QrcodeStream } from "vue-qrcode-reader";
|
||||
|
||||
import QuickNav from "../components/QuickNav.vue";
|
||||
import UserNameDialog from "../components/UserNameDialog.vue";
|
||||
import { NotificationIface, USE_DEXIE_DB } from "../constants/app";
|
||||
import { db, retrieveSettingsForActiveAccount } from "../db/index";
|
||||
import { NotificationIface } from "../constants/app";
|
||||
import { db } from "../db/index";
|
||||
import { Contact } from "../db/tables/contacts";
|
||||
import { MASTER_SETTINGS_KEY } from "../db/tables/settings";
|
||||
import * as databaseUtil from "../db/databaseUtil";
|
||||
@@ -246,10 +246,7 @@ export default class ContactQRScanShow extends Vue {
|
||||
|
||||
async created() {
|
||||
try {
|
||||
let settings = await databaseUtil.retrieveSettingsForActiveAccount();
|
||||
if (USE_DEXIE_DB) {
|
||||
settings = await retrieveSettingsForActiveAccount();
|
||||
}
|
||||
const settings = await databaseUtil.retrieveSettingsForActiveAccount();
|
||||
this.activeDid = settings.activeDid || "";
|
||||
this.apiServer = settings.apiServer || "";
|
||||
this.givenName = settings.firstName || "";
|
||||
@@ -598,9 +595,6 @@ export default class ContactQRScanShow extends Vue {
|
||||
"UPDATE contacts SET registered = ? WHERE did = ?",
|
||||
[true, contact.did],
|
||||
);
|
||||
if (USE_DEXIE_DB) {
|
||||
await db.contacts.update(contact.did, { registered: true });
|
||||
}
|
||||
logger.info("Contact registration successful", { did: contact.did });
|
||||
|
||||
this.$notify(
|
||||
@@ -786,12 +780,7 @@ export default class ContactQRScanShow extends Vue {
|
||||
const existingContacts = databaseUtil.mapQueryResultToValues(
|
||||
dbAllContacts,
|
||||
) as unknown as Contact[];
|
||||
let existingContact: Contact | undefined = existingContacts[0];
|
||||
if (USE_DEXIE_DB) {
|
||||
await db.open();
|
||||
const existingContacts = await db.contacts.toArray();
|
||||
existingContact = existingContacts.find((c) => c.did === contact.did);
|
||||
}
|
||||
const existingContact: Contact | undefined = existingContacts[0];
|
||||
|
||||
if (existingContact) {
|
||||
logger.info("Contact already exists", { did: contact.did });
|
||||
@@ -817,9 +806,6 @@ export default class ContactQRScanShow extends Vue {
|
||||
"contacts",
|
||||
);
|
||||
await platformService.dbExec(sql, params);
|
||||
if (USE_DEXIE_DB) {
|
||||
await db.contacts.add(contact);
|
||||
}
|
||||
|
||||
if (this.activeDid) {
|
||||
logger.info("Setting contact visibility", { did: contact.did });
|
||||
@@ -858,11 +844,6 @@ export default class ContactQRScanShow extends Vue {
|
||||
"UPDATE settings SET hideRegisterPromptOnNewContact = ? WHERE id = ?",
|
||||
[stopAsking, MASTER_SETTINGS_KEY],
|
||||
);
|
||||
if (USE_DEXIE_DB) {
|
||||
await db.settings.update(MASTER_SETTINGS_KEY, {
|
||||
hideRegisterPromptOnNewContact: stopAsking,
|
||||
});
|
||||
}
|
||||
this.hideRegisterPromptOnNewContact = stopAsking;
|
||||
}
|
||||
},
|
||||
@@ -873,11 +854,6 @@ export default class ContactQRScanShow extends Vue {
|
||||
"UPDATE settings SET hideRegisterPromptOnNewContact = ? WHERE id = ?",
|
||||
[stopAsking, MASTER_SETTINGS_KEY],
|
||||
);
|
||||
if (USE_DEXIE_DB) {
|
||||
await db.settings.update(MASTER_SETTINGS_KEY, {
|
||||
hideRegisterPromptOnNewContact: stopAsking,
|
||||
});
|
||||
}
|
||||
this.hideRegisterPromptOnNewContact = stopAsking;
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user