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 QuickNav from "../components/QuickNav.vue";
|
||||
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 * as serverUtil from "../libs/endorserServer";
|
||||
import { GenericCredWrapper, OfferClaim, ProviderInfo } from "../interfaces";
|
||||
import * as libsUtil from "../libs/util";
|
||||
import { logger } from "../utils/logger";
|
||||
import { PlatformServiceFactory } from "@/services/PlatformServiceFactory";
|
||||
import { PlatformServiceMixin } from "@/utils/PlatformServiceMixin";
|
||||
|
||||
@Component({
|
||||
components: { GiftedDialog, QuickNav },
|
||||
mixins: [PlatformServiceMixin],
|
||||
})
|
||||
export default class ClaimView extends Vue {
|
||||
$notify!: (notification: NotificationIface, timeout?: number) => void;
|
||||
@@ -630,24 +629,18 @@ export default class ClaimView extends Vue {
|
||||
}
|
||||
|
||||
async created() {
|
||||
const settings = await databaseUtil.retrieveSettingsForActiveAccount();
|
||||
const settings = await this.$settings();
|
||||
|
||||
this.activeDid = settings.activeDid || "";
|
||||
this.apiServer = settings.apiServer || "";
|
||||
const platformService = PlatformServiceFactory.getInstance();
|
||||
const dbAllContacts = await platformService.dbQuery(
|
||||
"SELECT * FROM contacts",
|
||||
);
|
||||
this.allContacts = databaseUtil.mapQueryResultToValues(
|
||||
dbAllContacts,
|
||||
) as unknown as Contact[];
|
||||
this.allContacts = await this.$contacts();
|
||||
|
||||
this.isRegistered = settings.isRegistered || false;
|
||||
|
||||
try {
|
||||
this.allMyDids = await libsUtil.retrieveAccountDids();
|
||||
} catch (error) {
|
||||
logConsoleAndDb(
|
||||
await logger.toConsoleAndDb(
|
||||
"Error retrieving all account DIDs on home page:" + error,
|
||||
true,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user