Browse Source

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)
pull/142/head
Matthew Raymer 1 day ago
parent
commit
d660339e41
  1. 17
      src/views/ClaimView.vue

17
src/views/ClaimView.vue

@ -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,
);

Loading…
Cancel
Save