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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user