forked from jsnbuchanan/crowd-funder-for-time-pwa
convert all remaining DB writes & reads to SQL (with successful registration & claim)
This commit is contained in:
@@ -232,10 +232,11 @@ import { RouteLocationNormalizedLoaded, Router } from "vue-router";
|
||||
import QuickNav from "../components/QuickNav.vue";
|
||||
import InfiniteScroll from "../components/InfiniteScroll.vue";
|
||||
import TopMessage from "../components/TopMessage.vue";
|
||||
import { NotificationIface } from "../constants/app";
|
||||
import { NotificationIface, USE_DEXIE_DB } from "../constants/app";
|
||||
import { db, retrieveSettingsForActiveAccount } from "../db/index";
|
||||
import { Contact } from "../db/tables/contacts";
|
||||
import { BoundingBox } from "../db/tables/settings";
|
||||
import * as databaseUtil from "../db/databaseUtil";
|
||||
import {
|
||||
GenericCredWrapper,
|
||||
GenericVerifiableCredential,
|
||||
@@ -253,6 +254,7 @@ import {
|
||||
import * as libsUtil from "../libs/util";
|
||||
import EntityIcon from "../components/EntityIcon.vue";
|
||||
import { logger } from "../utils/logger";
|
||||
import { PlatformServiceFactory } from "@/services/PlatformServiceFactory";
|
||||
|
||||
/**
|
||||
* DIDView Component
|
||||
@@ -323,7 +325,10 @@ export default class DIDView extends Vue {
|
||||
* Initializes component settings from active account
|
||||
*/
|
||||
private async initializeSettings() {
|
||||
const settings = await retrieveSettingsForActiveAccount();
|
||||
let settings = await databaseUtil.retrieveSettingsForActiveAccount();
|
||||
if (USE_DEXIE_DB) {
|
||||
settings = await retrieveSettingsForActiveAccount();
|
||||
}
|
||||
this.activeDid = settings.activeDid || "";
|
||||
this.apiServer = settings.apiServer || "";
|
||||
}
|
||||
@@ -370,7 +375,17 @@ export default class DIDView extends Vue {
|
||||
private async loadContactInformation() {
|
||||
if (!this.viewingDid) return;
|
||||
|
||||
this.contactFromDid = await db.contacts.get(this.viewingDid);
|
||||
const platformService = PlatformServiceFactory.getInstance();
|
||||
const dbContacts = await platformService.dbQuery(
|
||||
"SELECT * FROM contacts WHERE did = ?",
|
||||
[this.viewingDid],
|
||||
);
|
||||
this.contactFromDid = databaseUtil.mapQueryResultToValues(
|
||||
dbContacts,
|
||||
)[0] as unknown as Contact;
|
||||
if (USE_DEXIE_DB) {
|
||||
this.contactFromDid = await db.contacts.get(this.viewingDid);
|
||||
}
|
||||
if (this.contactFromDid) {
|
||||
this.contactYaml = yaml.dump(this.contactFromDid);
|
||||
}
|
||||
@@ -433,8 +448,14 @@ export default class DIDView extends Vue {
|
||||
* @param contact - Contact object to be deleted
|
||||
*/
|
||||
async deleteContact(contact: Contact) {
|
||||
await db.open();
|
||||
await db.contacts.delete(contact.did);
|
||||
const platformService = PlatformServiceFactory.getInstance();
|
||||
await platformService.dbExec("DELETE FROM contacts WHERE did = ?", [
|
||||
contact.did,
|
||||
]);
|
||||
if (USE_DEXIE_DB) {
|
||||
await db.open();
|
||||
await db.contacts.delete(contact.did);
|
||||
}
|
||||
this.$notify(
|
||||
{
|
||||
group: "alert",
|
||||
@@ -492,7 +513,14 @@ export default class DIDView extends Vue {
|
||||
);
|
||||
if (regResult.success) {
|
||||
contact.registered = true;
|
||||
await db.contacts.update(contact.did, { registered: true });
|
||||
const platformService = PlatformServiceFactory.getInstance();
|
||||
await platformService.dbExec(
|
||||
"UPDATE contacts SET registered = ? WHERE did = ?",
|
||||
[true, contact.did],
|
||||
);
|
||||
if (USE_DEXIE_DB) {
|
||||
await db.contacts.update(contact.did, { registered: true });
|
||||
}
|
||||
|
||||
this.$notify(
|
||||
{
|
||||
@@ -781,7 +809,14 @@ export default class DIDView extends Vue {
|
||||
const visibility = resp.data;
|
||||
contact.seesMe = visibility;
|
||||
//console.log("Visi check:", visibility, contact.seesMe, contact.did);
|
||||
await db.contacts.update(contact.did, { seesMe: visibility });
|
||||
const platformService = PlatformServiceFactory.getInstance();
|
||||
await platformService.dbExec(
|
||||
"UPDATE contacts SET seesMe = ? WHERE did = ?",
|
||||
[visibility, contact.did],
|
||||
);
|
||||
if (USE_DEXIE_DB) {
|
||||
await db.contacts.update(contact.did, { seesMe: visibility });
|
||||
}
|
||||
|
||||
this.$notify(
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user