convert all remaining DB writes & reads to SQL (with successful registration & claim)
This commit is contained in:
@@ -167,11 +167,30 @@
|
||||
<button
|
||||
class="text-sm text-blue-600 hover:text-blue-800 underline"
|
||||
@click="
|
||||
sqlQuery = 'SELECT * FROM sqlite_master WHERE type=\'table\';'
|
||||
sqlQuery = 'SELECT * FROM sqlite_master WHERE type=\'table\';';
|
||||
executeSql();
|
||||
"
|
||||
>
|
||||
All Tables
|
||||
</button>
|
||||
<button
|
||||
class="text-sm text-blue-600 hover:text-blue-800 underline"
|
||||
@click="
|
||||
sqlQuery = 'SELECT * FROM accounts;';
|
||||
executeSql();
|
||||
"
|
||||
>
|
||||
Accounts
|
||||
</button>
|
||||
<button
|
||||
class="text-sm text-blue-600 hover:text-blue-800 underline"
|
||||
@click="
|
||||
sqlQuery = 'SELECT * FROM settings;';
|
||||
executeSql();
|
||||
"
|
||||
>
|
||||
Settings
|
||||
</button>
|
||||
</div>
|
||||
<div>
|
||||
<textarea
|
||||
@@ -311,7 +330,8 @@ import { Component, Vue } from "vue-facing-decorator";
|
||||
import { Router } from "vue-router";
|
||||
|
||||
import QuickNav from "../components/QuickNav.vue";
|
||||
import { AppString, NotificationIface } from "../constants/app";
|
||||
import { AppString, NotificationIface, USE_DEXIE_DB } from "../constants/app";
|
||||
import * as databaseUtil from "../db/databaseUtil";
|
||||
import { db, retrieveSettingsForActiveAccount } from "../db/index";
|
||||
import * as vcLib from "../libs/crypto/vc";
|
||||
import * as cryptoLib from "../libs/crypto";
|
||||
@@ -331,6 +351,7 @@ import {
|
||||
} from "../libs/util";
|
||||
import { logger } from "../utils/logger";
|
||||
import { PlatformServiceFactory } from "@/services/PlatformServiceFactory";
|
||||
import { Temp } from "@/db/tables/temp";
|
||||
const inputFileNameRef = ref<Blob>();
|
||||
|
||||
const TEST_PAYLOAD = {
|
||||
@@ -369,7 +390,10 @@ export default class Help extends Vue {
|
||||
cryptoLib = cryptoLib;
|
||||
|
||||
async mounted() {
|
||||
const settings = await retrieveSettingsForActiveAccount();
|
||||
let settings = await databaseUtil.retrieveSettingsForActiveAccount();
|
||||
if (USE_DEXIE_DB) {
|
||||
settings = await retrieveSettingsForActiveAccount();
|
||||
}
|
||||
this.activeDid = settings.activeDid || "";
|
||||
this.userName = settings.firstName;
|
||||
|
||||
@@ -399,11 +423,35 @@ export default class Help extends Vue {
|
||||
});
|
||||
const blobB64 = await blobToBase64(blob);
|
||||
this.fileName = (file as File).name;
|
||||
const temp = await db.temp.get(SHARED_PHOTO_BASE64_KEY);
|
||||
|
||||
const platformService = PlatformServiceFactory.getInstance();
|
||||
const tempQuery = await platformService.dbQuery(
|
||||
"SELECT * FROM temp WHERE id = ?",
|
||||
[SHARED_PHOTO_BASE64_KEY],
|
||||
);
|
||||
let temp = databaseUtil.mapQueryResultToValues(
|
||||
tempQuery,
|
||||
)?.[0] as Temp;
|
||||
if (temp) {
|
||||
await db.temp.update(SHARED_PHOTO_BASE64_KEY, { blobB64 });
|
||||
await platformService.dbExec(
|
||||
"UPDATE temp SET blobB64 = ? WHERE id = ?",
|
||||
[blobB64, SHARED_PHOTO_BASE64_KEY],
|
||||
);
|
||||
} else {
|
||||
await db.temp.add({ id: SHARED_PHOTO_BASE64_KEY, blobB64 });
|
||||
await platformService.dbExec(
|
||||
"INSERT INTO temp (id, blobB64) VALUES (?, ?)",
|
||||
[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 });
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user