convert all remaining DB writes & reads to SQL (with successful registration & claim)

This commit is contained in:
2025-05-27 21:07:24 -06:00
parent f0d8fdf98c
commit 8092d1c576
67 changed files with 1200 additions and 266 deletions

View File

@@ -78,12 +78,16 @@ 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";
import { MASTER_SETTINGS_KEY } from "../db/tables/settings";
import { accessToken } from "../libs/crypto";
import { base64ToBlob, SHARED_PHOTO_BASE64_KEY } from "../libs/util";
import { logger } from "../utils/logger";
import { PlatformServiceFactory } from "@/services/PlatformServiceFactory";
import { Temp } from "@/db/tables/temp";
@Component({ components: { PhotoDialog, QuickNav } })
export default class SharedPhotoView extends Vue {
$notify!: (notification: NotificationIface, timeout?: number) => void;
@@ -100,16 +104,32 @@ export default class SharedPhotoView extends Vue {
// 'created' hook runs when the Vue instance is first created
async mounted() {
try {
const settings = await retrieveSettingsForActiveAccount();
let settings = await databaseUtil.retrieveSettingsForActiveAccount();
if (USE_DEXIE_DB) {
settings = await retrieveSettingsForActiveAccount();
}
this.activeDid = settings.activeDid;
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 (USE_DEXIE_DB) {
temp = (await db.temp.get(SHARED_PHOTO_BASE64_KEY)) as unknown as Temp;
}
const imageB64 = temp?.blobB64 as string;
if (temp) {
this.imageBlob = base64ToBlob(imageB64);
// clear the temp image
db.temp.delete(SHARED_PHOTO_BASE64_KEY);
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 {
@@ -150,9 +170,12 @@ export default class SharedPhotoView extends Vue {
recordProfile() {
(this.$refs.photoDialog as PhotoDialog).open(
async (imgUrl) => {
await db.settings.update(MASTER_SETTINGS_KEY, {
profileImageUrl: 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,