Browse Source

Fix notify initialization and axios access errors

- ContactQRScanShowView: Move notify initialization to created() lifecycle hook
- DIDView: Remove axios getter accessing non-existent platformService.axios
- DIDView: Enhance setVisibility() with proper server API error handling
offer-validation-logic
Matthew Raymer 6 days ago
parent
commit
f98d6c7020
  1. 8
      src/views/ContactQRScanShowView.vue
  2. 19
      src/views/DIDView.vue

8
src/views/ContactQRScanShowView.vue

@ -213,15 +213,11 @@ export default class ContactQRScanShow extends Vue {
$router!: Router; $router!: Router;
// Notification helper system // Notification helper system
private notify = createNotifyHelpers(this.$notify); notify!: ReturnType<typeof createNotifyHelpers>;
activeDid = ""; activeDid = "";
apiServer = ""; apiServer = "";
// Axios instance for API calls
get axios() {
return (this as any).$platformService.axios;
}
givenName = ""; givenName = "";
hideRegisterPromptOnNewContact = false; hideRegisterPromptOnNewContact = false;
isRegistered = false; isRegistered = false;
@ -288,6 +284,8 @@ export default class ContactQRScanShow extends Vue {
} }
async created() { async created() {
this.notify = createNotifyHelpers(this.$notify);
try { try {
const settings = await this.$accountSettings(); const settings = await this.$accountSettings();
this.activeDid = settings.activeDid || ""; this.activeDid = settings.activeDid || "";

19
src/views/DIDView.vue

@ -273,6 +273,7 @@ import {
displayAmount, displayAmount,
getHeaders, getHeaders,
register, register,
setVisibilityUtil,
} from "../libs/endorserServer"; } from "../libs/endorserServer";
import * as libsUtil from "../libs/util"; import * as libsUtil from "../libs/util";
import EntityIcon from "../components/EntityIcon.vue"; import EntityIcon from "../components/EntityIcon.vue";
@ -324,6 +325,7 @@ export default class DIDView extends Vue {
apiServer = ""; apiServer = "";
claims: Array<GenericCredWrapper<GenericVerifiableCredential>> = []; claims: Array<GenericCredWrapper<GenericVerifiableCredential>> = [];
contactFromDid?: Contact; contactFromDid?: Contact;
contactYaml = ""; contactYaml = "";
hitEnd = false; hitEnd = false;
isLoading = false; isLoading = false;
@ -722,9 +724,15 @@ export default class DIDView extends Vue {
visibility: boolean, visibility: boolean,
showSuccessAlert: boolean, showSuccessAlert: boolean,
) { ) {
// Update contact visibility using mixin method const result = await setVisibilityUtil(
await this.$updateContact(contact.did, { seesMe: visibility }); this.activeDid,
this.apiServer,
this.axios,
contact,
visibility,
);
if (result.success) {
if (showSuccessAlert) { if (showSuccessAlert) {
const message = const message =
(contact.name || "That user") + (contact.name || "That user") +
@ -734,6 +742,13 @@ export default class DIDView extends Vue {
this.notify.success(message, TIMEOUTS.SHORT); this.notify.success(message, TIMEOUTS.SHORT);
} }
return true; return true;
} else {
logger.error("Got strange result from setting visibility:", result);
const message =
(result.error as string) || "Could not set visibility on the server.";
this.notify.error(message, TIMEOUTS.LONG);
return false;
}
} }
/** /**

Loading…
Cancel
Save