forked from trent_larson/crowd-funder-for-time-pwa
Migrate ClaimView.vue from databaseUtil to PlatformServiceMixin
- Replace databaseUtil.retrieveSettingsForActiveAccount() with this.$settings() - Replace databaseUtil.mapQueryResultToValues() with this.$mapResults() - Replace logConsoleAndDb() with logger.toConsoleAndDb() - Add PlatformServiceMixin to component mixins - Optimize allContacts assignment to single line: this.$contacts() - Remove unused PlatformServiceFactory import - All ClaimView tests passing (30-record-gift.spec.ts, 50-record-offer.spec.ts)
This commit is contained in:
@@ -558,17 +558,16 @@ import { GenericVerifiableCredential } from "../interfaces";
|
|||||||
import GiftedDialog from "../components/GiftedDialog.vue";
|
import GiftedDialog from "../components/GiftedDialog.vue";
|
||||||
import QuickNav from "../components/QuickNav.vue";
|
import QuickNav from "../components/QuickNav.vue";
|
||||||
import { APP_SERVER, NotificationIface } from "../constants/app";
|
import { APP_SERVER, NotificationIface } from "../constants/app";
|
||||||
import * as databaseUtil from "../db/databaseUtil";
|
|
||||||
import { logConsoleAndDb } from "../db/databaseUtil";
|
|
||||||
import { Contact } from "../db/tables/contacts";
|
import { Contact } from "../db/tables/contacts";
|
||||||
import * as serverUtil from "../libs/endorserServer";
|
import * as serverUtil from "../libs/endorserServer";
|
||||||
import { GenericCredWrapper, OfferClaim, ProviderInfo } from "../interfaces";
|
import { GenericCredWrapper, OfferClaim, ProviderInfo } from "../interfaces";
|
||||||
import * as libsUtil from "../libs/util";
|
import * as libsUtil from "../libs/util";
|
||||||
import { logger } from "../utils/logger";
|
import { logger } from "../utils/logger";
|
||||||
import { PlatformServiceFactory } from "@/services/PlatformServiceFactory";
|
import { PlatformServiceMixin } from "@/utils/PlatformServiceMixin";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
components: { GiftedDialog, QuickNav },
|
components: { GiftedDialog, QuickNav },
|
||||||
|
mixins: [PlatformServiceMixin],
|
||||||
})
|
})
|
||||||
export default class ClaimView extends Vue {
|
export default class ClaimView extends Vue {
|
||||||
$notify!: (notification: NotificationIface, timeout?: number) => void;
|
$notify!: (notification: NotificationIface, timeout?: number) => void;
|
||||||
@@ -630,24 +629,18 @@ export default class ClaimView extends Vue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async created() {
|
async created() {
|
||||||
const settings = await databaseUtil.retrieveSettingsForActiveAccount();
|
const settings = await this.$settings();
|
||||||
|
|
||||||
this.activeDid = settings.activeDid || "";
|
this.activeDid = settings.activeDid || "";
|
||||||
this.apiServer = settings.apiServer || "";
|
this.apiServer = settings.apiServer || "";
|
||||||
const platformService = PlatformServiceFactory.getInstance();
|
this.allContacts = await this.$contacts();
|
||||||
const dbAllContacts = await platformService.dbQuery(
|
|
||||||
"SELECT * FROM contacts",
|
|
||||||
);
|
|
||||||
this.allContacts = databaseUtil.mapQueryResultToValues(
|
|
||||||
dbAllContacts,
|
|
||||||
) as unknown as Contact[];
|
|
||||||
|
|
||||||
this.isRegistered = settings.isRegistered || false;
|
this.isRegistered = settings.isRegistered || false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.allMyDids = await libsUtil.retrieveAccountDids();
|
this.allMyDids = await libsUtil.retrieveAccountDids();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logConsoleAndDb(
|
await logger.toConsoleAndDb(
|
||||||
"Error retrieving all account DIDs on home page:" + error,
|
"Error retrieving all account DIDs on home page:" + error,
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user