convert all remaining DB writes & reads to SQL (with successful registration & claim)
This commit is contained in:
@@ -112,10 +112,12 @@ import {
|
||||
import { Router } from "vue-router";
|
||||
|
||||
import QuickNav from "../components/QuickNav.vue";
|
||||
import { NotificationIface } from "../constants/app";
|
||||
import { NotificationIface, USE_DEXIE_DB } 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 { logger } from "../utils/logger";
|
||||
|
||||
const DEFAULT_LAT_LONG_DIFF = 0.01;
|
||||
const WORLD_ZOOM = 2;
|
||||
const DEFAULT_ZOOM = 2;
|
||||
@@ -147,7 +149,10 @@ export default class SearchAreaView extends Vue {
|
||||
searchBox: { name: string; bbox: BoundingBox } | null = null;
|
||||
|
||||
async mounted() {
|
||||
const settings = await retrieveSettingsForActiveAccount();
|
||||
let settings = await databaseUtil.retrieveSettingsForActiveAccount();
|
||||
if (USE_DEXIE_DB) {
|
||||
settings = await retrieveSettingsForActiveAccount();
|
||||
}
|
||||
this.searchBox = settings.searchBoxes?.[0] || null;
|
||||
this.resetLatLong();
|
||||
}
|
||||
@@ -204,10 +209,15 @@ export default class SearchAreaView extends Vue {
|
||||
westLong: this.localCenterLong - this.localLongDiff,
|
||||
},
|
||||
};
|
||||
await db.open();
|
||||
await db.settings.update(MASTER_SETTINGS_KEY, {
|
||||
searchBoxes: [newSearchBox],
|
||||
});
|
||||
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: [newSearchBox],
|
||||
});
|
||||
}
|
||||
this.searchBox = newSearchBox;
|
||||
this.isChoosingSearchBox = false;
|
||||
|
||||
@@ -251,11 +261,18 @@ export default class SearchAreaView extends Vue {
|
||||
|
||||
public async forgetSearchBox() {
|
||||
try {
|
||||
await db.open();
|
||||
await db.settings.update(MASTER_SETTINGS_KEY, {
|
||||
searchBoxes: [],
|
||||
// @ts-expect-error - the DB requires searchBoxes to be a string
|
||||
await databaseUtil.updateDefaultSettings({
|
||||
searchBoxes: "[]",
|
||||
filterFeedByNearby: false,
|
||||
});
|
||||
if (USE_DEXIE_DB) {
|
||||
await db.open();
|
||||
await db.settings.update(MASTER_SETTINGS_KEY, {
|
||||
searchBoxes: [],
|
||||
filterFeedByNearby: false,
|
||||
});
|
||||
}
|
||||
this.searchBox = null;
|
||||
this.localCenterLat = 0;
|
||||
this.localCenterLong = 0;
|
||||
|
||||
Reference in New Issue
Block a user