From daed0a97c9e06338e9a9cfdd885b8d110a92fd37 Mon Sep 17 00:00:00 2001 From: Matthew Raymer Date: Mon, 23 Jun 2025 08:25:10 +0000 Subject: [PATCH] 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. --- src/App.vue | 8 +- src/components/DataExportSection.vue | 4 - src/components/FeedFilters.vue | 32 +- src/components/GiftedDialog.vue | 10 +- src/components/GiftedPrompts.vue | 11 +- src/components/ImageMethodDialog.vue | 11 +- src/components/MembersList.vue | 16 +- src/components/OfferDialog.vue | 7 +- src/components/OnboardingDialog.vue | 29 +- src/components/PhotoDialog.vue | 11 +- src/components/PushNotificationPermission.vue | 11 +- src/components/TopMessage.vue | 7 +- src/components/UserNameDialog.vue | 12 +- .../World/components/objects/landmarks.js | 6 +- src/constants/app.ts | 2 - src/db/index.ts | 2 +- src/db/tables/accounts.ts | 2 +- src/interfaces/index.ts | 1 + src/libs/endorserServer.ts | 4 - src/libs/util.ts | 108 +- src/router/index.ts | 5 - src/services/indexedDBMigrationService.ts | 1397 --------------- .../platforms/CapacitorPlatformService.ts | 2 +- src/test/index.ts | 7 +- src/views/AccountViewView.vue | 224 +-- src/views/ClaimAddRawView.vue | 7 +- src/views/ClaimCertificateView.vue | 14 +- src/views/ClaimReportCertificateView.vue | 13 +- src/views/ClaimView.vue | 12 +- src/views/ConfirmGiftView.vue | 11 +- src/views/ContactAmountsView.vue | 11 +- src/views/ContactEditView.vue | 16 +- src/views/ContactGiftingView.vue | 16 +- src/views/ContactImportView.vue | 31 +- src/views/ContactQRScanFullView.vue | 17 +- src/views/ContactQRScanShowView.vue | 32 +- src/views/ContactsView.vue | 75 +- src/views/DIDView.vue | 32 +- src/views/DatabaseMigration.vue | 1492 ----------------- src/views/DiscoverView.vue | 9 +- src/views/GiftedDetailsView.vue | 16 +- src/views/HelpNotificationsView.vue | 8 +- src/views/HelpView.vue | 12 +- src/views/HomeView.vue | 54 +- src/views/IdentitySwitcherView.vue | 18 +- src/views/ImportAccountView.vue | 8 +- src/views/ImportDerivedAccountView.vue | 6 - src/views/InviteOneAcceptView.vue | 14 +- src/views/InviteOneView.vue | 22 +- src/views/LogView.vue | 13 +- src/views/NewActivityView.vue | 50 +- src/views/NewEditAccountView.vue | 14 +- src/views/NewEditProjectView.vue | 11 +- src/views/OfferDetailsView.vue | 11 +- src/views/OnboardMeetingListView.vue | 6 +- src/views/OnboardMeetingMembersView.vue | 7 +- src/views/OnboardMeetingSetupView.vue | 7 +- src/views/ProjectViewView.vue | 11 +- src/views/ProjectsView.vue | 12 +- src/views/QuickActionBvcBeginView.vue | 18 +- src/views/QuickActionBvcEndView.vue | 17 +- src/views/RecentOffersToUserProjectsView.vue | 12 +- src/views/RecentOffersToUserView.vue | 10 +- src/views/SearchAreaView.vue | 23 +- src/views/SeedBackupView.vue | 8 +- src/views/ShareMyContactInfoView.vue | 12 +- src/views/SharedPhotoView.vue | 19 +- src/views/StartView.vue | 7 +- src/views/TestView.vue | 19 +- src/views/UserProfileView.vue | 9 +- 70 files changed, 185 insertions(+), 3986 deletions(-) delete mode 100644 src/services/indexedDBMigrationService.ts delete mode 100644 src/views/DatabaseMigration.vue diff --git a/src/App.vue b/src/App.vue index 5d4b0f51..df47c4a4 100644 --- a/src/App.vue +++ b/src/App.vue @@ -331,9 +331,8 @@ diff --git a/src/views/DiscoverView.vue b/src/views/DiscoverView.vue index 07bde02f..57dea288 100644 --- a/src/views/DiscoverView.vue +++ b/src/views/DiscoverView.vue @@ -323,7 +323,6 @@ import TopMessage from "../components/TopMessage.vue"; import { NotificationIface, DEFAULT_PARTNER_API_SERVER, - USE_DEXIE_DB, } from "../constants/app"; import { db, @@ -402,10 +401,7 @@ export default class DiscoverView extends Vue { const searchPeople = !!this.$route.query["searchPeople"]; - let settings = await databaseUtil.retrieveSettingsForActiveAccount(); - if (USE_DEXIE_DB) { - settings = await retrieveSettingsForActiveAccount(); - } + const settings = await databaseUtil.retrieveSettingsForActiveAccount(); this.activeDid = (settings.activeDid as string) || ""; this.apiServer = (settings.apiServer as string) || ""; this.partnerApiServer = @@ -415,9 +411,6 @@ export default class DiscoverView extends Vue { const platformService = PlatformServiceFactory.getInstance(); const dbContacts = await platformService.dbQuery("SELECT * FROM contacts"); this.allContacts = databaseUtil.mapQueryResultToValues(dbContacts) as unknown as Contact[]; - if (USE_DEXIE_DB) { - this.allContacts = await db.contacts.toArray(); - } this.allMyDids = await retrieveAccountDids(); diff --git a/src/views/GiftedDetailsView.vue b/src/views/GiftedDetailsView.vue index 277546bc..bde3e280 100644 --- a/src/views/GiftedDetailsView.vue +++ b/src/views/GiftedDetailsView.vue @@ -261,11 +261,7 @@ import { RouteLocationNormalizedLoaded, Router } from "vue-router"; import ImageMethodDialog from "../components/ImageMethodDialog.vue"; import QuickNav from "../components/QuickNav.vue"; import TopMessage from "../components/TopMessage.vue"; -import { - DEFAULT_IMAGE_API_SERVER, - NotificationIface, - USE_DEXIE_DB, -} from "../constants/app"; +import { DEFAULT_IMAGE_API_SERVER, NotificationIface } from "../constants/app"; import { db, retrieveSettingsForActiveAccount } from "../db/index"; import * as databaseUtil from "../db/databaseUtil"; import { GenericCredWrapper, GiveActionClaim } from "../interfaces"; @@ -428,10 +424,7 @@ export default class GiftedDetails extends Vue { this.imageUrl = this.$route.query["shareUrl"] as string; } - let settings = await databaseUtil.retrieveSettingsForActiveAccount(); - if (USE_DEXIE_DB) { - settings = await retrieveSettingsForActiveAccount(); - } + const settings = await databaseUtil.retrieveSettingsForActiveAccount(); this.apiServer = settings.apiServer || ""; this.activeDid = settings.activeDid || ""; @@ -443,12 +436,9 @@ export default class GiftedDetails extends Vue { const dbContacts = await platformService.dbQuery( "SELECT * FROM contacts", ); - let allContacts = databaseUtil.mapQueryResultToValues( + const allContacts = databaseUtil.mapQueryResultToValues( dbContacts, ) as unknown as Contact[]; - if (USE_DEXIE_DB) { - allContacts = await db.contacts.toArray(); - } const allMyDids = await retrieveAccountDids(); if (this.giverDid && !this.giverName) { this.giverName = didInfo( diff --git a/src/views/HelpNotificationsView.vue b/src/views/HelpNotificationsView.vue index e1e3901d..3ea599cb 100644 --- a/src/views/HelpNotificationsView.vue +++ b/src/views/HelpNotificationsView.vue @@ -308,7 +308,7 @@ import { Component, Vue } from "vue-facing-decorator"; import QuickNav from "../components/QuickNav.vue"; -import { NotificationIface, USE_DEXIE_DB } from "../constants/app"; +import { NotificationIface } from "../constants/app"; import { DIRECT_PUSH_TITLE, sendTestThroughPushServer } from "../libs/util"; import PushNotificationPermission from "../components/PushNotificationPermission.vue"; import { db } from "../db/index"; @@ -426,12 +426,6 @@ export default class HelpNotificationsView extends Vue { notifyingReminderMessage: message, notifyingReminderTime: timeText, }); - if (USE_DEXIE_DB) { - await db.settings.update(MASTER_SETTINGS_KEY, { - notifyingReminderMessage: message, - notifyingReminderTime: timeText, - }); - } this.notifyingReminder = true; this.notifyingReminderMessage = message || ""; this.notifyingReminderTime = timeText; diff --git a/src/views/HelpView.vue b/src/views/HelpView.vue index dea5eb27..5b279e00 100644 --- a/src/views/HelpView.vue +++ b/src/views/HelpView.vue @@ -601,7 +601,7 @@ import { Capacitor } from "@capacitor/core"; import * as Package from "../../package.json"; import QuickNav from "../components/QuickNav.vue"; -import { APP_SERVER, NotificationIface, USE_DEXIE_DB } from "../constants/app"; +import { APP_SERVER, NotificationIface } from "../constants/app"; import * as databaseUtil from "../db/databaseUtil"; import { retrieveSettingsForActiveAccount, @@ -638,20 +638,12 @@ export default class HelpView extends Vue { } async unsetFinishedOnboarding() { - let settings = await databaseUtil.retrieveSettingsForActiveAccount(); - if (USE_DEXIE_DB) { - settings = await retrieveSettingsForActiveAccount(); - } + const settings = await databaseUtil.retrieveSettingsForActiveAccount(); if (settings.activeDid) { await databaseUtil.updateDidSpecificSettings(settings.activeDid, { finishedOnboarding: false, }); - if (USE_DEXIE_DB) { - await updateAccountSettings(settings.activeDid, { - finishedOnboarding: false, - }); - } } this.$router.push({ name: "home" }); } diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue index 49919da9..0ea51383 100644 --- a/src/views/HomeView.vue +++ b/src/views/HomeView.vue @@ -318,14 +318,8 @@ import { AppString, NotificationIface, PASSKEYS_ENABLED, - USE_DEXIE_DB, } from "../constants/app"; -import { - db, - logConsoleAndDb, - retrieveSettingsForActiveAccount, - updateAccountSettings, -} from "../db/index"; +import { logConsoleAndDb } from "../db/index"; import { Contact } from "../db/tables/contacts"; import { BoundingBox, @@ -552,9 +546,6 @@ export default class HomeView extends Vue { let settings; try { settings = await databaseUtil.retrieveSettingsForActiveAccount(); - if (USE_DEXIE_DB) { - settings = await retrieveSettingsForActiveAccount(); - } } catch (error) { logConsoleAndDb( `[HomeView] Failed to retrieve settings: ${error}`, @@ -623,12 +614,6 @@ export default class HomeView extends Vue { isRegistered: true, ...(await databaseUtil.retrieveSettingsForActiveAccount()), }); - if (USE_DEXIE_DB) { - await updateAccountSettings(this.activeDid, { - isRegistered: true, - ...(await retrieveSettingsForActiveAccount()), - }); - } this.isRegistered = true; } } catch (error) { @@ -707,10 +692,7 @@ export default class HomeView extends Vue { * Called by mounted() and reloadFeedOnChange() */ private async loadSettings() { - let settings = await databaseUtil.retrieveSettingsForActiveAccount(); - if (USE_DEXIE_DB) { - settings = await retrieveSettingsForActiveAccount(); - } + const settings = await databaseUtil.retrieveSettingsForActiveAccount(); this.apiServer = settings.apiServer || ""; this.activeDid = settings.activeDid || ""; this.feedLastViewedClaimId = settings.lastViewedClaimId; @@ -739,9 +721,6 @@ export default class HomeView extends Vue { this.allContacts = databaseUtil.mapQueryResultToValues( dbContacts, ) as unknown as Contact[]; - if (USE_DEXIE_DB) { - this.allContacts = await db.contacts.toArray(); - } this.blockedContactDids = this.allContacts .filter((c) => !c.iViewContent) .map((c) => c.did); @@ -765,22 +744,13 @@ export default class HomeView extends Vue { this.activeDid, ); if (resp.status === 200) { - let settings = await databaseUtil.retrieveSettingsForActiveAccount(); - if (USE_DEXIE_DB) { - settings = await retrieveSettingsForActiveAccount(); - } + const settings = + await databaseUtil.retrieveSettingsForActiveAccount(); await databaseUtil.updateDidSpecificSettings(this.activeDid, { apiServer: this.apiServer, isRegistered: true, ...settings, }); - if (USE_DEXIE_DB) { - await updateAccountSettings(this.activeDid, { - apiServer: this.apiServer, - isRegistered: true, - ...settings, - }); - } this.isRegistered = true; } } catch (e) { @@ -841,10 +811,7 @@ export default class HomeView extends Vue { * Called by mounted() */ private async checkOnboarding() { - let settings = await databaseUtil.retrieveSettingsForActiveAccount(); - if (USE_DEXIE_DB) { - settings = await retrieveSettingsForActiveAccount(); - } + const settings = await databaseUtil.retrieveSettingsForActiveAccount(); if (!settings.finishedOnboarding) { (this.$refs.onboardingDialog as OnboardingDialog).open(OnboardPage.Home); } @@ -913,10 +880,7 @@ export default class HomeView extends Vue { * Called by FeedFilters component when filters change */ async reloadFeedOnChange() { - let settings = await databaseUtil.retrieveSettingsForActiveAccount(); - if (USE_DEXIE_DB) { - settings = await retrieveSettingsForActiveAccount(); - } + const settings = await databaseUtil.retrieveSettingsForActiveAccount(); this.isFeedFilteredByVisible = !!settings.filterFeedByVisible; this.isFeedFilteredByNearby = !!settings.filterFeedByNearby; this.isAnyFeedFilterOn = checkIsAnyFeedFilterOn(settings); @@ -1364,12 +1328,6 @@ export default class HomeView extends Vue { await databaseUtil.updateDefaultSettings({ lastViewedClaimId: records[0].jwtId, }); - if (USE_DEXIE_DB) { - await db.open(); - await db.settings.update(MASTER_SETTINGS_KEY, { - lastViewedClaimId: records[0].jwtId, - }); - } } } diff --git a/src/views/IdentitySwitcherView.vue b/src/views/IdentitySwitcherView.vue index 8d4a08be..55a122b3 100644 --- a/src/views/IdentitySwitcherView.vue +++ b/src/views/IdentitySwitcherView.vue @@ -105,7 +105,7 @@ import { Component, Vue } from "vue-facing-decorator"; import { Router } from "vue-router"; import QuickNav from "../components/QuickNav.vue"; -import { NotificationIface, USE_DEXIE_DB } from "../constants/app"; +import { NotificationIface } from "../constants/app"; import { accountsDBPromise, db, @@ -130,10 +130,7 @@ export default class IdentitySwitcherView 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.apiServerInput = settings.apiServer || ""; @@ -165,12 +162,6 @@ export default class IdentitySwitcherView extends Vue { async switchAccount(did?: string) { await databaseUtil.updateDefaultSettings({ activeDid: did }); - if (USE_DEXIE_DB) { - await db.open(); - await db.settings.update(MASTER_SETTINGS_KEY, { - activeDid: did, - }); - } this.$router.push({ name: "account" }); } @@ -186,11 +177,6 @@ export default class IdentitySwitcherView extends Vue { await platformService.dbExec(`DELETE FROM accounts WHERE id = ?`, [ id, ]); - if (USE_DEXIE_DB) { - // one of the few times we use accountsDBPromise directly; try to avoid more usage - const accountsDB = await accountsDBPromise; - await accountsDB.accounts.delete(id); - } this.otherIdentities = this.otherIdentities.filter( (ident) => ident.id !== id, ); diff --git a/src/views/ImportAccountView.vue b/src/views/ImportAccountView.vue index 76caa7bf..e576a35d 100644 --- a/src/views/ImportAccountView.vue +++ b/src/views/ImportAccountView.vue @@ -86,9 +86,8 @@ import { Component, Vue } from "vue-facing-decorator"; import { Router } from "vue-router"; -import { AppString, NotificationIface, USE_DEXIE_DB } from "../constants/app"; +import { AppString, NotificationIface } from "../constants/app"; import * as databaseUtil from "../db/databaseUtil"; -import { retrieveSettingsForActiveAccount } from "../db/index"; import { DEFAULT_ROOT_DERIVATION_PATH } from "../libs/crypto"; import { retrieveAccountCount, importFromMnemonic } from "../libs/util"; import { logger } from "../utils/logger"; @@ -116,10 +115,7 @@ export default class ImportAccountView extends Vue { async created() { this.numAccounts = await retrieveAccountCount(); // get the server, to help with import on the test server - let settings = await databaseUtil.retrieveSettingsForActiveAccount(); - if (USE_DEXIE_DB) { - settings = await retrieveSettingsForActiveAccount(); - } + const settings = await databaseUtil.retrieveSettingsForActiveAccount(); this.apiServer = settings.apiServer || ""; } diff --git a/src/views/ImportDerivedAccountView.vue b/src/views/ImportDerivedAccountView.vue index 5e5ff232..d0a5bbd6 100644 --- a/src/views/ImportDerivedAccountView.vue +++ b/src/views/ImportDerivedAccountView.vue @@ -90,7 +90,6 @@ import { import { logger } from "../utils/logger"; import { Account, AccountEncrypted } from "../db/tables/accounts"; import { PlatformServiceFactory } from "@/services/PlatformServiceFactory"; -import { USE_DEXIE_DB } from "@/constants/app"; @Component({ components: {}, @@ -174,11 +173,6 @@ export default class ImportAccountView extends Vue { await databaseUtil.updateDidSpecificSettings(newId.did, { isRegistered: false, }); - if (USE_DEXIE_DB) { - await db.settings.update(MASTER_SETTINGS_KEY, { - activeDid: newId.did, - }); - } this.$router.push({ name: "account" }); } catch (err) { logger.error("Error saving mnemonic & updating settings:", err); diff --git a/src/views/InviteOneAcceptView.vue b/src/views/InviteOneAcceptView.vue index 9a107c9d..c25c4db8 100644 --- a/src/views/InviteOneAcceptView.vue +++ b/src/views/InviteOneAcceptView.vue @@ -42,12 +42,8 @@ import { Component, Vue } from "vue-facing-decorator"; import { Router, RouteLocationNormalized } from "vue-router"; import QuickNav from "../components/QuickNav.vue"; -import { APP_SERVER, NotificationIface, USE_DEXIE_DB } from "../constants/app"; -import { - db, - logConsoleAndDb, - retrieveSettingsForActiveAccount, -} from "../db/index"; +import { APP_SERVER, NotificationIface } from "../constants/app"; +import { logConsoleAndDb } from "../db/index"; import * as databaseUtil from "../db/databaseUtil"; import { decodeEndorserJwt } from "../libs/crypto/vc"; import { errorStringForLog } from "../libs/endorserServer"; @@ -115,11 +111,7 @@ export default class InviteOneAcceptView extends Vue { this.checkingInvite = true; // Load or generate identity - let settings = await databaseUtil.retrieveSettingsForActiveAccount(); - if (USE_DEXIE_DB) { - await db.open(); - settings = await retrieveSettingsForActiveAccount(); - } + const settings = await databaseUtil.retrieveSettingsForActiveAccount(); this.activeDid = settings.activeDid || ""; this.apiServer = settings.apiServer || ""; diff --git a/src/views/InviteOneView.vue b/src/views/InviteOneView.vue index 4a2e4c6c..7d8be6d4 100644 --- a/src/views/InviteOneView.vue +++ b/src/views/InviteOneView.vue @@ -138,13 +138,7 @@ import ContactNameDialog from "../components/ContactNameDialog.vue"; import QuickNav from "../components/QuickNav.vue"; import TopMessage from "../components/TopMessage.vue"; import InviteDialog from "../components/InviteDialog.vue"; -import { - APP_SERVER, - AppString, - NotificationIface, - USE_DEXIE_DB, -} from "../constants/app"; -import { db, retrieveSettingsForActiveAccount } from "../db/index"; +import { APP_SERVER, AppString, NotificationIface } from "../constants/app"; import { Contact } from "../db/tables/contacts"; import * as databaseUtil from "../db/databaseUtil"; import { createInviteJwt, getHeaders } from "../libs/endorserServer"; @@ -176,11 +170,7 @@ export default class InviteOneView extends Vue { async mounted() { try { - let settings = await databaseUtil.retrieveSettingsForActiveAccount(); - if (USE_DEXIE_DB) { - await db.open(); - settings = await retrieveSettingsForActiveAccount(); - } + const settings = await databaseUtil.retrieveSettingsForActiveAccount(); this.activeDid = settings.activeDid || ""; this.apiServer = settings.apiServer || ""; this.isRegistered = !!settings.isRegistered; @@ -196,12 +186,9 @@ export default class InviteOneView extends Vue { const queryResult = await platformService.dbQuery( "SELECT * FROM contacts", ); - let baseContacts = databaseUtil.mapQueryResultToValues( + const baseContacts = databaseUtil.mapQueryResultToValues( queryResult, ) as unknown as Contact[]; - if (USE_DEXIE_DB) { - baseContacts = await db.contacts.toArray(); - } for (const invite of this.invites) { const contact = baseContacts.find( (contact) => contact.did === invite.redeemedBy, @@ -365,9 +352,6 @@ export default class InviteOneView extends Vue { const placeholders = values.map(() => "?").join(", "); const sql = `INSERT INTO contacts (${columns.join(", ")}) VALUES (${placeholders})`; await platformService.dbExec(sql, values); - if (USE_DEXIE_DB) { - await db.contacts.add(contact); - } this.contactsRedeemed[did] = contact; this.$notify( diff --git a/src/views/LogView.vue b/src/views/LogView.vue index 8ef7bc39..4762b6c7 100644 --- a/src/views/LogView.vue +++ b/src/views/LogView.vue @@ -62,7 +62,6 @@ import { db } from "../db/index"; import { Log } from "../db/tables/logs"; import { logger } from "../utils/logger"; import { PlatformServiceFactory } from "../services/PlatformServiceFactory"; -import { USE_DEXIE_DB } from "../constants/app"; import * as databaseUtil from "../db/databaseUtil"; @Component({ @@ -88,7 +87,7 @@ export default class LogView extends Vue { this.error = null; // Clear any previous errors this.memoryLogs = databaseUtil.memoryLogs; - let allLogs: Log[] = []; + const allLogs: Log[] = []; const platformService = PlatformServiceFactory.getInstance(); const queryResult = await platformService.dbQuery( "SELECT * FROM logs ORDER BY date DESC", @@ -96,16 +95,6 @@ export default class LogView extends Vue { this.logs = databaseUtil.mapQueryResultToValues( queryResult, ) as unknown as Log[]; - if (USE_DEXIE_DB) { - await db.open(); - allLogs = await db.logs.toArray(); - // Sort by date in reverse chronological order - this.logs = allLogs.sort((a, b) => { - const dateA = new Date(a.date); - const dateB = new Date(b.date); - return dateB.getTime() - dateA.getTime(); - }); - } } catch (error) { logger.error("Error loading logs:", error); this.error = diff --git a/src/views/NewActivityView.vue b/src/views/NewActivityView.vue index b13a145a..e86fe8d9 100644 --- a/src/views/NewActivityView.vue +++ b/src/views/NewActivityView.vue @@ -153,15 +153,9 @@ import { Component, Vue } from "vue-facing-decorator"; import GiftedDialog from "../components/GiftedDialog.vue"; import QuickNav from "../components/QuickNav.vue"; import EntityIcon from "../components/EntityIcon.vue"; -import { NotificationIface, USE_DEXIE_DB } from "../constants/app"; -import { - db, - retrieveSettingsForActiveAccount, - updateAccountSettings, -} from "../db/index"; +import { NotificationIface } from "../constants/app"; import { Contact } from "../db/tables/contacts"; import { Router } from "vue-router"; -import { OfferSummaryRecord, OfferToPlanSummaryRecord } from "../interfaces"; import { didInfo, displayAmount, @@ -197,10 +191,7 @@ export default class NewActivityView extends Vue { async created() { try { - let settings = await databaseUtil.retrieveSettingsForActiveAccount(); - if (USE_DEXIE_DB) { - settings = await retrieveSettingsForActiveAccount(); - } + const settings = await databaseUtil.retrieveSettingsForActiveAccount(); this.apiServer = settings.apiServer || ""; this.activeDid = settings.activeDid || ""; this.lastAckedOfferToUserJwtId = settings.lastAckedOfferToUserJwtId || ""; @@ -214,10 +205,6 @@ export default class NewActivityView extends Vue { this.allContacts = databaseUtil.mapQueryResultToValues( queryResult, ) as unknown as Contact[]; - if (USE_DEXIE_DB) { - await db.open(); - this.allContacts = await db.contacts.toArray(); - } this.allMyDids = await retrieveAccountDids(); @@ -260,11 +247,6 @@ export default class NewActivityView extends Vue { await databaseUtil.updateDidSpecificSettings(this.activeDid, { lastAckedOfferToUserJwtId: this.newOffersToUser[0].jwtId, }); - if (USE_DEXIE_DB) { - await updateAccountSettings(this.activeDid, { - lastAckedOfferToUserJwtId: this.newOffersToUser[0].jwtId, - }); - } // note that we don't update this.lastAckedOfferToUserJwtId in case they // later choose the last one to keep the offers as new this.$notify( @@ -288,21 +270,11 @@ export default class NewActivityView extends Vue { await databaseUtil.updateDidSpecificSettings(this.activeDid, { lastAckedOfferToUserJwtId: this.newOffersToUser[index + 1].jwtId, }); - if (USE_DEXIE_DB) { - await db.settings.update(this.activeDid, { - lastAckedOfferToUserJwtId: this.newOffersToUser[index + 1].jwtId, - }); - } } else { // it's the last entry (or not found), so just keep it the same await databaseUtil.updateDidSpecificSettings(this.activeDid, { lastAckedOfferToUserJwtId: this.lastAckedOfferToUserJwtId, }); - if (USE_DEXIE_DB) { - await db.settings.update(this.activeDid, { - lastAckedOfferToUserJwtId: this.lastAckedOfferToUserJwtId, - }); - } } this.$notify( { @@ -323,12 +295,6 @@ export default class NewActivityView extends Vue { lastAckedOfferToUserProjectsJwtId: this.newOffersToUserProjects[0].jwtId, }); - if (USE_DEXIE_DB) { - await db.settings.update(this.activeDid, { - lastAckedOfferToUserProjectsJwtId: - this.newOffersToUserProjects[0].jwtId, - }); - } // note that we don't update this.lastAckedOfferToUserProjectsJwtId in case // they later choose the last one to keep the offers as new this.$notify( @@ -353,24 +319,12 @@ export default class NewActivityView extends Vue { lastAckedOfferToUserProjectsJwtId: this.newOffersToUserProjects[index + 1].jwtId, }); - if (USE_DEXIE_DB) { - await db.settings.update(this.activeDid, { - lastAckedOfferToUserProjectsJwtId: - this.newOffersToUserProjects[index + 1].jwtId, - }); - } } else { // it's the last entry (or not found), so just keep it the same await databaseUtil.updateDidSpecificSettings(this.activeDid, { lastAckedOfferToUserProjectsJwtId: this.lastAckedOfferToUserProjectsJwtId, }); - if (USE_DEXIE_DB) { - await db.settings.update(this.activeDid, { - lastAckedOfferToUserProjectsJwtId: - this.lastAckedOfferToUserProjectsJwtId, - }); - } } this.$notify( { diff --git a/src/views/NewEditAccountView.vue b/src/views/NewEditAccountView.vue index 126170ab..97a0e4be 100644 --- a/src/views/NewEditAccountView.vue +++ b/src/views/NewEditAccountView.vue @@ -47,9 +47,6 @@ import { Component, Vue } from "vue-facing-decorator"; import { Router } from "vue-router"; -import { USE_DEXIE_DB } from "@/constants/app"; -import { db, retrieveSettingsForActiveAccount } from "../db/index"; -import { MASTER_SETTINGS_KEY } from "../db/tables/settings"; import * as databaseUtil from "../db/databaseUtil"; @Component({ @@ -62,10 +59,7 @@ export default class NewEditAccountView extends Vue { // 'created' hook runs when the Vue instance is first created async created() { - let settings = await databaseUtil.retrieveSettingsForActiveAccount(); - if (USE_DEXIE_DB) { - settings = await retrieveSettingsForActiveAccount(); - } + const settings = await databaseUtil.retrieveSettingsForActiveAccount(); this.givenName = (settings.firstName || "") + (settings.lastName ? ` ${settings.lastName}` : ""); // deprecated, pre v 0.1.3 @@ -76,12 +70,6 @@ export default class NewEditAccountView extends Vue { firstName: this.givenName, lastName: "", // deprecated, pre v 0.1.3 }); - if (USE_DEXIE_DB) { - await db.settings.update(MASTER_SETTINGS_KEY, { - firstName: this.givenName, - lastName: "", // deprecated, pre v 0.1.3 - }); - } this.$router.back(); } diff --git a/src/views/NewEditProjectView.vue b/src/views/NewEditProjectView.vue index ff54e52e..a2fbaf47 100644 --- a/src/views/NewEditProjectView.vue +++ b/src/views/NewEditProjectView.vue @@ -237,7 +237,6 @@ import { DEFAULT_IMAGE_API_SERVER, DEFAULT_PARTNER_API_SERVER, NotificationIface, - USE_DEXIE_DB, } from "../constants/app"; import * as databaseUtil from "../db/databaseUtil"; import { retrieveSettingsForActiveAccount } from "../db/index"; @@ -305,10 +304,7 @@ export default class NewEditProjectView extends Vue { async mounted() { this.numAccounts = await retrieveAccountCount(); - 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.showGeneralAdvanced = !!settings.showGeneralAdvanced; @@ -707,10 +703,7 @@ export default class NewEditProjectView extends Vue { ) { try { let partnerServer = DEFAULT_PARTNER_API_SERVER; - let settings = await databaseUtil.retrieveSettingsForActiveAccount(); - if (USE_DEXIE_DB) { - settings = await retrieveSettingsForActiveAccount(); - } + const settings = await databaseUtil.retrieveSettingsForActiveAccount(); if (settings.partnerApiServer) { partnerServer = settings.partnerApiServer; } diff --git a/src/views/OfferDetailsView.vue b/src/views/OfferDetailsView.vue index 1c88fbba..0bbd11d3 100644 --- a/src/views/OfferDetailsView.vue +++ b/src/views/OfferDetailsView.vue @@ -180,7 +180,7 @@ import { RouteLocationNormalizedLoaded, Router } from "vue-router"; import QuickNav from "../components/QuickNav.vue"; import TopMessage from "../components/TopMessage.vue"; -import { NotificationIface, USE_DEXIE_DB } from "../constants/app"; +import { NotificationIface } from "../constants/app"; import { db, retrieveSettingsForActiveAccount } from "../db/index"; import { GenericCredWrapper, OfferClaim } from "../interfaces"; import { @@ -402,10 +402,7 @@ export default class OfferDetailsView extends Vue { * @throws Will not throw but logs errors */ private async loadAccountSettings() { - let settings = await databaseUtil.retrieveSettingsForActiveAccount(); - if (USE_DEXIE_DB) { - settings = await retrieveSettingsForActiveAccount(); - } + const settings = await databaseUtil.retrieveSettingsForActiveAccount(); this.apiServer = settings.apiServer ?? ""; this.activeDid = settings.activeDid ?? ""; this.showGeneralAdvanced = settings.showGeneralAdvanced ?? false; @@ -424,10 +421,6 @@ export default class OfferDetailsView extends Vue { allContacts = databaseUtil.mapQueryResultToValues( queryResult, ) as unknown as Contact[]; - if (USE_DEXIE_DB) { - await db.open(); - allContacts = await db.contacts.toArray(); - } const allMyDids = await retrieveAccountDids(); this.recipientName = didInfo( this.recipientDid, diff --git a/src/views/OnboardMeetingListView.vue b/src/views/OnboardMeetingListView.vue index f514cc21..75c8e868 100644 --- a/src/views/OnboardMeetingListView.vue +++ b/src/views/OnboardMeetingListView.vue @@ -98,7 +98,6 @@ import { serverMessageForUser, } from "../libs/endorserServer"; import { encryptMessage } from "../libs/crypto"; -import { USE_DEXIE_DB } from "@/constants/app"; interface Meeting { name: string; @@ -137,10 +136,7 @@ export default class OnboardMeetingListView extends Vue { showPasswordDialog = false; async created() { - 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.firstName = settings.firstName || ""; diff --git a/src/views/OnboardMeetingMembersView.vue b/src/views/OnboardMeetingMembersView.vue index 20cdbcac..b7de0e28 100644 --- a/src/views/OnboardMeetingMembersView.vue +++ b/src/views/OnboardMeetingMembersView.vue @@ -56,7 +56,6 @@ import TopMessage from "../components/TopMessage.vue"; import MembersList from "../components/MembersList.vue"; import UserNameDialog from "../components/UserNameDialog.vue"; import * as databaseUtil from "../db/databaseUtil"; -import { retrieveSettingsForActiveAccount } from "../db/index"; import { logConsoleAndDb } from "../db/databaseUtil"; import { encryptMessage } from "../libs/crypto"; import { @@ -65,7 +64,6 @@ import { serverMessageForUser, } from "../libs/endorserServer"; import { generateSaveAndActivateIdentity } from "../libs/util"; -import { USE_DEXIE_DB } from "@/constants/app"; @Component({ components: { @@ -107,10 +105,7 @@ export default class OnboardMeetingMembersView extends Vue { this.isLoading = false; return; } - 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.firstName = settings.firstName || ""; diff --git a/src/views/OnboardMeetingSetupView.vue b/src/views/OnboardMeetingSetupView.vue index cee9029f..1d1882b9 100644 --- a/src/views/OnboardMeetingSetupView.vue +++ b/src/views/OnboardMeetingSetupView.vue @@ -285,7 +285,7 @@ import { } from "../libs/endorserServer"; import { encryptMessage } from "../libs/crypto"; import { logger } from "../utils/logger"; -import { APP_SERVER, USE_DEXIE_DB } from "@/constants/app"; +import { APP_SERVER } from "@/constants/app"; interface ServerMeeting { groupId: number; // from the server name: string; // to & from the server @@ -332,10 +332,7 @@ export default class OnboardMeetingView extends Vue { } async created() { - 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.fullName = settings.firstName || ""; diff --git a/src/views/ProjectViewView.vue b/src/views/ProjectViewView.vue index 15c9cf4d..66d820fa 100644 --- a/src/views/ProjectViewView.vue +++ b/src/views/ProjectViewView.vue @@ -642,7 +642,7 @@ import TopMessage from "../components/TopMessage.vue"; import QuickNav from "../components/QuickNav.vue"; import EntityIcon from "../components/EntityIcon.vue"; import ProjectIcon from "../components/ProjectIcon.vue"; -import { APP_SERVER, NotificationIface, USE_DEXIE_DB } from "../constants/app"; +import { APP_SERVER, NotificationIface } from "../constants/app"; import * as databaseUtil from "../db/databaseUtil"; import { db, @@ -799,10 +799,7 @@ export default class ProjectViewView extends Vue { * @emits Notification on profile loading errors */ async created() { - 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 || ""; const platformService = PlatformServiceFactory.getInstance(); @@ -810,10 +807,6 @@ export default class ProjectViewView extends Vue { this.allContacts = databaseUtil.mapQueryResultToValues( queryResult, ) as unknown as Contact[]; - if (USE_DEXIE_DB) { - await db.open(); - this.allContacts = await db.contacts.toArray(); - } this.isRegistered = !!settings.isRegistered; try { diff --git a/src/views/ProjectsView.vue b/src/views/ProjectsView.vue index f3ebd5ba..ccdfab67 100644 --- a/src/views/ProjectsView.vue +++ b/src/views/ProjectsView.vue @@ -270,8 +270,7 @@ import { Component, Vue } from "vue-facing-decorator"; import { Router } from "vue-router"; import { Capacitor } from "@capacitor/core"; -import { NotificationIface, USE_DEXIE_DB } from "../constants/app"; -import { db, retrieveSettingsForActiveAccount } from "../db/index"; +import { NotificationIface } from "../constants/app"; import EntityIcon from "../components/EntityIcon.vue"; import InfiniteScroll from "../components/InfiniteScroll.vue"; import QuickNav from "../components/QuickNav.vue"; @@ -327,10 +326,7 @@ export default class ProjectsView extends Vue { async mounted() { 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.isRegistered = !!settings.isRegistered; @@ -343,10 +339,6 @@ export default class ProjectsView extends Vue { this.allContacts = databaseUtil.mapQueryResultToValues( queryResult, ) as unknown as Contact[]; - if (USE_DEXIE_DB) { - await db.open(); - this.allContacts = await db.contacts.toArray(); - } this.allMyDids = await libsUtil.retrieveAccountDids(); diff --git a/src/views/QuickActionBvcBeginView.vue b/src/views/QuickActionBvcBeginView.vue index 596b1ca5..4bc4b47e 100644 --- a/src/views/QuickActionBvcBeginView.vue +++ b/src/views/QuickActionBvcBeginView.vue @@ -72,9 +72,8 @@ import { Component, Vue } from "vue-facing-decorator"; import QuickNav from "../components/QuickNav.vue"; import TopMessage from "../components/TopMessage.vue"; -import { NotificationIface, USE_DEXIE_DB } from "../constants/app"; +import { NotificationIface } from "../constants/app"; import * as databaseUtil from "../db/databaseUtil"; -import { retrieveSettingsForActiveAccount } from "../db/index"; import { BVC_MEETUPS_PROJECT_CLAIM_ID, bvcMeetingJoinClaim, @@ -118,10 +117,7 @@ export default class QuickActionBvcBeginView extends Vue { } async record() { - let settings = await databaseUtil.retrieveSettingsForActiveAccount(); - if (USE_DEXIE_DB) { - settings = await retrieveSettingsForActiveAccount(); - } + const settings = await databaseUtil.retrieveSettingsForActiveAccount(); const activeDid = settings.activeDid || ""; const apiServer = settings.apiServer || ""; @@ -144,7 +140,7 @@ export default class QuickActionBvcBeginView extends Vue { "HUR", BVC_MEETUPS_PROJECT_CLAIM_ID, ); - if (timeResult.type === "success") { + if (timeResult.success) { timeSuccess = true; } else { logger.error("Error sending time:", timeResult); @@ -153,9 +149,7 @@ export default class QuickActionBvcBeginView extends Vue { group: "alert", type: "danger", title: "Error", - text: - timeResult?.error?.userMessage || - "There was an error sending the time.", + text: timeResult?.error || "There was an error sending the time.", }, 5000, ); @@ -171,7 +165,7 @@ export default class QuickActionBvcBeginView extends Vue { apiServer, axios, ); - if (attendResult.type === "success") { + if (attendResult.success) { attendedSuccess = true; } else { logger.error("Error sending attendance:", attendResult); @@ -181,7 +175,7 @@ export default class QuickActionBvcBeginView extends Vue { type: "danger", title: "Error", text: - attendResult?.error?.userMessage || + attendResult?.error || "There was an error sending the attendance.", }, 5000, diff --git a/src/views/QuickActionBvcEndView.vue b/src/views/QuickActionBvcEndView.vue index 97468328..30bcf1d1 100644 --- a/src/views/QuickActionBvcEndView.vue +++ b/src/views/QuickActionBvcEndView.vue @@ -144,7 +144,7 @@ import { Router } from "vue-router"; import QuickNav from "../components/QuickNav.vue"; import TopMessage from "../components/TopMessage.vue"; -import { NotificationIface, USE_DEXIE_DB } from "../constants/app"; +import { NotificationIface } from "../constants/app"; import * as databaseUtil from "../db/databaseUtil"; import { accountsDBPromise, @@ -194,10 +194,7 @@ export default class QuickActionBvcBeginView extends Vue { async created() { this.loadingConfirms = true; - let settings = await databaseUtil.retrieveSettingsForActiveAccount(); - if (USE_DEXIE_DB) { - settings = await retrieveSettingsForActiveAccount(); - } + const settings = await databaseUtil.retrieveSettingsForActiveAccount(); this.apiServer = settings.apiServer || ""; this.activeDid = settings.activeDid || ""; @@ -208,10 +205,6 @@ export default class QuickActionBvcBeginView extends Vue { this.allContacts = databaseUtil.mapQueryResultToValues( contactQueryResult, ) as unknown as Contact[]; - if (USE_DEXIE_DB) { - await db.open(); - this.allContacts = await db.contacts.toArray(); - } let currentOrPreviousSat = DateTime.now().setZone("America/Denver"); if (currentOrPreviousSat.weekday < 6) { @@ -233,12 +226,6 @@ export default class QuickActionBvcBeginView extends Vue { this.allMyDids = (await retrieveAllAccountsMetadata()).map( (account) => account.did, ); - if (USE_DEXIE_DB) { - const accountsDB = await accountsDBPromise; - await accountsDB.open(); - const allAccounts = await accountsDB.accounts.toArray(); - this.allMyDids = allAccounts.map((acc) => acc.did); - } const headers = await getHeaders(this.activeDid); try { const response = await fetch( diff --git a/src/views/RecentOffersToUserProjectsView.vue b/src/views/RecentOffersToUserProjectsView.vue index e613b82c..893550f0 100644 --- a/src/views/RecentOffersToUserProjectsView.vue +++ b/src/views/RecentOffersToUserProjectsView.vue @@ -83,9 +83,8 @@ import EntityIcon from "../components/EntityIcon.vue"; import GiftedDialog from "../components/GiftedDialog.vue"; import InfiniteScroll from "../components/InfiniteScroll.vue"; import QuickNav from "../components/QuickNav.vue"; -import { NotificationIface, USE_DEXIE_DB } from "../constants/app"; +import { NotificationIface } from "../constants/app"; import * as databaseUtil from "../db/databaseUtil"; -import { db, retrieveSettingsForActiveAccount } from "../db/index"; import { Contact } from "../db/tables/contacts"; import { Router } from "vue-router"; import { OfferToPlanSummaryRecord } from "../interfaces"; @@ -118,10 +117,7 @@ export default class RecentOffersToUserView extends Vue { async created() { try { - let settings = await databaseUtil.retrieveSettingsForActiveAccount(); - if (USE_DEXIE_DB) { - settings = await retrieveSettingsForActiveAccount(); - } + const settings = await databaseUtil.retrieveSettingsForActiveAccount(); this.apiServer = settings.apiServer || ""; this.activeDid = settings.activeDid || ""; this.lastAckedOfferToUserProjectsJwtId = @@ -134,10 +130,6 @@ export default class RecentOffersToUserView extends Vue { this.allContacts = databaseUtil.mapQueryResultToValues( contactQueryResult, ) as unknown as Contact[]; - if (USE_DEXIE_DB) { - await db.open(); - this.allContacts = await db.contacts.toArray(); - } this.allMyDids = await retrieveAccountDids(); diff --git a/src/views/RecentOffersToUserView.vue b/src/views/RecentOffersToUserView.vue index 8f2ab687..db7bdf31 100644 --- a/src/views/RecentOffersToUserView.vue +++ b/src/views/RecentOffersToUserView.vue @@ -76,7 +76,7 @@ import GiftedDialog from "../components/GiftedDialog.vue"; import EntityIcon from "../components/EntityIcon.vue"; import InfiniteScroll from "../components/InfiniteScroll.vue"; import QuickNav from "../components/QuickNav.vue"; -import { NotificationIface, USE_DEXIE_DB } from "../constants/app"; +import { NotificationIface } from "../constants/app"; import * as databaseUtil from "../db/databaseUtil"; import { db, retrieveSettingsForActiveAccount } from "../db/index"; import { Contact } from "../db/tables/contacts"; @@ -110,10 +110,7 @@ export default class RecentOffersToUserView extends Vue { async created() { try { - let settings = await databaseUtil.retrieveSettingsForActiveAccount(); - if (USE_DEXIE_DB) { - settings = await retrieveSettingsForActiveAccount(); - } + const settings = await databaseUtil.retrieveSettingsForActiveAccount(); this.apiServer = settings.apiServer || ""; this.activeDid = settings.activeDid || ""; this.lastAckedOfferToUserJwtId = settings.lastAckedOfferToUserJwtId || ""; @@ -125,9 +122,6 @@ export default class RecentOffersToUserView extends Vue { this.allContacts = databaseUtil.mapQueryResultToValues( contactQueryResult, ) as unknown as Contact[]; - if (USE_DEXIE_DB) { - this.allContacts = await db.contacts.toArray(); - } this.allMyDids = await retrieveAccountDids(); diff --git a/src/views/SearchAreaView.vue b/src/views/SearchAreaView.vue index 4646d1f0..48a484ba 100644 --- a/src/views/SearchAreaView.vue +++ b/src/views/SearchAreaView.vue @@ -112,10 +112,9 @@ import { import { Router } from "vue-router"; import QuickNav from "../components/QuickNav.vue"; -import { NotificationIface, USE_DEXIE_DB } from "../constants/app"; +import { NotificationIface } from "../constants/app"; import * as databaseUtil from "../db/databaseUtil"; -import { db, retrieveSettingsForActiveAccount } from "../db/index"; -import { BoundingBox, MASTER_SETTINGS_KEY } from "../db/tables/settings"; +import { BoundingBox } from "../db/tables/settings"; import { logger } from "../utils/logger"; const DEFAULT_LAT_LONG_DIFF = 0.01; @@ -149,10 +148,7 @@ export default class SearchAreaView extends Vue { searchBox: { name: string; bbox: BoundingBox } | null = null; async mounted() { - let settings = await databaseUtil.retrieveSettingsForActiveAccount(); - if (USE_DEXIE_DB) { - settings = await retrieveSettingsForActiveAccount(); - } + const settings = await databaseUtil.retrieveSettingsForActiveAccount(); this.searchBox = settings.searchBoxes?.[0] || null; this.resetLatLong(); } @@ -212,12 +208,6 @@ export default class SearchAreaView extends Vue { const searchBoxes = JSON.stringify([newSearchBox]); // @ts-expect-error - the DB requires searchBoxes to be a string databaseUtil.updateDefaultSettings({ searchBoxes }); - if (USE_DEXIE_DB) { - await db.open(); - await db.settings.update(MASTER_SETTINGS_KEY, { - searchBoxes: searchBoxes as unknown, // Type assertion for Dexie compatibility - }); - } this.searchBox = newSearchBox; this.isChoosingSearchBox = false; @@ -266,13 +256,6 @@ export default class SearchAreaView extends Vue { searchBoxes: "[]", filterFeedByNearby: false, }); - if (USE_DEXIE_DB) { - await db.open(); - await db.settings.update(MASTER_SETTINGS_KEY, { - searchBoxes: "[]" as unknown as string, // Type assertion for Dexie compatibility - filterFeedByNearby: false, - }); - } this.searchBox = null; this.localCenterLat = 0; this.localCenterLong = 0; diff --git a/src/views/SeedBackupView.vue b/src/views/SeedBackupView.vue index f86ac4e3..c3afe0ea 100644 --- a/src/views/SeedBackupView.vue +++ b/src/views/SeedBackupView.vue @@ -109,8 +109,7 @@ import { Component, Vue } from "vue-facing-decorator"; import { useClipboard } from "@vueuse/core"; import QuickNav from "../components/QuickNav.vue"; -import { NotificationIface, USE_DEXIE_DB } from "../constants/app"; -import { retrieveSettingsForActiveAccount } from "../db/index"; +import { NotificationIface } from "../constants/app"; import { Account } from "../db/tables/accounts"; import * as databaseUtil from "../db/databaseUtil"; import { @@ -136,11 +135,6 @@ export default class SeedBackupView extends Vue { const settings = await databaseUtil.retrieveSettingsForActiveAccount(); activeDid = settings.activeDid || ""; - if (USE_DEXIE_DB) { - const settings = await retrieveSettingsForActiveAccount(); - activeDid = settings.activeDid || ""; - } - this.numAccounts = await retrieveAccountCount(); this.activeAccount = await retrieveFullyDecryptedAccount(activeDid); } catch (err: unknown) { diff --git a/src/views/ShareMyContactInfoView.vue b/src/views/ShareMyContactInfoView.vue index ca1f2e94..1a8a2a63 100644 --- a/src/views/ShareMyContactInfoView.vue +++ b/src/views/ShareMyContactInfoView.vue @@ -46,7 +46,7 @@ import { Router } from "vue-router"; import { useClipboard } from "@vueuse/core"; import QuickNav from "../components/QuickNav.vue"; import TopMessage from "../components/TopMessage.vue"; -import { NotificationIface, APP_SERVER, USE_DEXIE_DB } from "../constants/app"; +import { NotificationIface, APP_SERVER } from "../constants/app"; import * as databaseUtil from "../db/databaseUtil"; import { db, retrieveSettingsForActiveAccount } from "../db/index"; import { retrieveFullyDecryptedAccount } from "../libs/util"; @@ -66,10 +66,7 @@ export default class ShareMyContactInfoView extends Vue { } async onClickShare() { - let settings = await databaseUtil.retrieveSettingsForActiveAccount(); - if (USE_DEXIE_DB) { - settings = await retrieveSettingsForActiveAccount(); - } + const settings = await databaseUtil.retrieveSettingsForActiveAccount(); const activeDid = settings.activeDid || ""; const givenName = settings.firstName || ""; const isRegistered = !!settings.isRegistered; @@ -81,13 +78,10 @@ export default class ShareMyContactInfoView extends Vue { const contactQueryResult = await platformService.dbQuery( "SELECT COUNT(*) FROM contacts", ); - let numContacts = + const numContacts = (databaseUtil.mapQueryResultToValues( contactQueryResult, )?.[0]?.[0] as number) || 0; - if (USE_DEXIE_DB) { - numContacts = await db.contacts.count(); - } if (account) { const message = await generateEndorserJwtUrlForAccount( diff --git a/src/views/SharedPhotoView.vue b/src/views/SharedPhotoView.vue index 7fb7606a..dc02cc8b 100644 --- a/src/views/SharedPhotoView.vue +++ b/src/views/SharedPhotoView.vue @@ -78,7 +78,6 @@ import { DEFAULT_IMAGE_API_SERVER, IMAGE_TYPE_PROFILE, NotificationIface, - USE_DEXIE_DB, } from "../constants/app"; import * as databaseUtil from "../db/databaseUtil"; import { db, retrieveSettingsForActiveAccount } from "../db/index"; @@ -104,10 +103,7 @@ export default class SharedPhotoView extends Vue { // 'created' hook runs when the Vue instance is first created async mounted() { try { - let settings = await databaseUtil.retrieveSettingsForActiveAccount(); - if (USE_DEXIE_DB) { - settings = await retrieveSettingsForActiveAccount(); - } + const settings = await databaseUtil.retrieveSettingsForActiveAccount(); this.activeDid = settings.activeDid; const platformService = PlatformServiceFactory.getInstance(); @@ -115,10 +111,7 @@ export default class SharedPhotoView extends Vue { "SELECT * FROM temp WHERE id = ?", [SHARED_PHOTO_BASE64_KEY], ); - let temp = databaseUtil.mapQueryResultToValues(tempQuery)?.[0] as Temp; - if (USE_DEXIE_DB) { - temp = (await db.temp.get(SHARED_PHOTO_BASE64_KEY)) as unknown as Temp; - } + const temp = databaseUtil.mapQueryResultToValues(tempQuery)?.[0] as Temp; const imageB64 = temp?.blobB64 as string; if (temp) { this.imageBlob = base64ToBlob(imageB64); @@ -127,9 +120,6 @@ export default class SharedPhotoView extends Vue { await platformService.dbExec("DELETE FROM temp WHERE id = ?", [ SHARED_PHOTO_BASE64_KEY, ]); - if (USE_DEXIE_DB) { - await db.temp.delete(SHARED_PHOTO_BASE64_KEY); - } this.imageFileName = this.$route.query["fileName"] as string; } else { @@ -171,11 +161,6 @@ export default class SharedPhotoView extends Vue { (this.$refs.photoDialog as PhotoDialog).open( async (imgUrl) => { databaseUtil.updateDefaultSettings({ profileImageUrl: imgUrl }); - if (USE_DEXIE_DB) { - await db.settings.update(MASTER_SETTINGS_KEY, { - profileImageUrl: imgUrl, - }); - } this.$router.push({ name: "account" }); }, IMAGE_TYPE_PROFILE, diff --git a/src/views/StartView.vue b/src/views/StartView.vue index 5fb8f728..e91f4fc4 100644 --- a/src/views/StartView.vue +++ b/src/views/StartView.vue @@ -103,7 +103,7 @@ import { Component, Vue } from "vue-facing-decorator"; import { Router } from "vue-router"; -import { AppString, PASSKEYS_ENABLED, USE_DEXIE_DB } from "../constants/app"; +import { AppString, PASSKEYS_ENABLED } from "../constants/app"; import * as databaseUtil from "../db/databaseUtil"; import { retrieveSettingsForActiveAccount } from "../db/index"; import { @@ -122,10 +122,7 @@ export default class StartView extends Vue { numAccounts = 0; async mounted() { - let settings = await databaseUtil.retrieveSettingsForActiveAccount(); - if (USE_DEXIE_DB) { - settings = await retrieveSettingsForActiveAccount(); - } + const settings = await databaseUtil.retrieveSettingsForActiveAccount(); this.givenName = settings.firstName || ""; this.numAccounts = await retrieveAccountCount(); diff --git a/src/views/TestView.vue b/src/views/TestView.vue index ae703664..f9d3ee5d 100644 --- a/src/views/TestView.vue +++ b/src/views/TestView.vue @@ -339,7 +339,7 @@ import { Component, Vue } from "vue-facing-decorator"; import { Router } from "vue-router"; import QuickNav from "../components/QuickNav.vue"; -import { AppString, NotificationIface, USE_DEXIE_DB } from "../constants/app"; +import { AppString, NotificationIface } from "../constants/app"; import * as databaseUtil from "../db/databaseUtil"; import { db, retrieveSettingsForActiveAccount } from "../db/index"; import * as vcLib from "../libs/crypto/vc"; @@ -399,10 +399,7 @@ export default class Help extends Vue { cryptoLib = cryptoLib; async mounted() { - let settings = await databaseUtil.retrieveSettingsForActiveAccount(); - if (USE_DEXIE_DB) { - settings = await retrieveSettingsForActiveAccount(); - } + const settings = await databaseUtil.retrieveSettingsForActiveAccount(); this.activeDid = settings.activeDid || ""; this.userName = settings.firstName; @@ -438,7 +435,7 @@ export default class Help extends Vue { "SELECT * FROM temp WHERE id = ?", [SHARED_PHOTO_BASE64_KEY], ); - let temp = databaseUtil.mapQueryResultToValues( + const temp = databaseUtil.mapQueryResultToValues( tempQuery, )?.[0] as Temp; if (temp) { @@ -452,16 +449,6 @@ export default class Help extends Vue { [SHARED_PHOTO_BASE64_KEY, blobB64], ); } - if (USE_DEXIE_DB) { - temp = (await db.temp.get( - SHARED_PHOTO_BASE64_KEY, - )) as unknown as Temp; - if (temp) { - await db.temp.update(SHARED_PHOTO_BASE64_KEY, { blobB64 }); - } else { - await db.temp.add({ id: SHARED_PHOTO_BASE64_KEY, blobB64 }); - } - } } }; reader.readAsArrayBuffer(file as Blob); diff --git a/src/views/UserProfileView.vue b/src/views/UserProfileView.vue index 1defd348..224ce9d9 100644 --- a/src/views/UserProfileView.vue +++ b/src/views/UserProfileView.vue @@ -110,7 +110,6 @@ import { APP_SERVER, DEFAULT_PARTNER_API_SERVER, NotificationIface, - USE_DEXIE_DB, } from "../constants/app"; import * as databaseUtil from "../db/databaseUtil"; import { db } from "../db/index"; @@ -152,12 +151,9 @@ export default class UserProfileView extends Vue { const settingsQuery = await platformService.dbQuery( "SELECT * FROM settings", ); - let settings = databaseUtil.mapQueryResultToValues( + const settings = databaseUtil.mapQueryResultToValues( settingsQuery, ) as Settings[]; - if (USE_DEXIE_DB) { - settings = await db.settings.toArray(); - } this.activeDid = settings[0]?.activeDid || ""; this.partnerApiServer = settings[0]?.partnerApiServer || this.partnerApiServer; @@ -168,9 +164,6 @@ export default class UserProfileView extends Vue { this.allContacts = databaseUtil.mapQueryResultToValues( contactQuery, ) as unknown as Contact[]; - if (USE_DEXIE_DB) { - this.allContacts = await db.contacts.toArray(); - } this.allMyDids = await retrieveAccountDids(); await this.loadProfile();