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
This commit is contained in:
@@ -213,15 +213,11 @@ export default class ContactQRScanShow extends Vue {
|
||||
$router!: Router;
|
||||
|
||||
// Notification helper system
|
||||
private notify = createNotifyHelpers(this.$notify);
|
||||
notify!: ReturnType<typeof createNotifyHelpers>;
|
||||
|
||||
activeDid = "";
|
||||
apiServer = "";
|
||||
|
||||
// Axios instance for API calls
|
||||
get axios() {
|
||||
return (this as any).$platformService.axios;
|
||||
}
|
||||
givenName = "";
|
||||
hideRegisterPromptOnNewContact = false;
|
||||
isRegistered = false;
|
||||
@@ -288,6 +284,8 @@ export default class ContactQRScanShow extends Vue {
|
||||
}
|
||||
|
||||
async created() {
|
||||
this.notify = createNotifyHelpers(this.$notify);
|
||||
|
||||
try {
|
||||
const settings = await this.$accountSettings();
|
||||
this.activeDid = settings.activeDid || "";
|
||||
|
||||
@@ -273,6 +273,7 @@ import {
|
||||
displayAmount,
|
||||
getHeaders,
|
||||
register,
|
||||
setVisibilityUtil,
|
||||
} from "../libs/endorserServer";
|
||||
import * as libsUtil from "../libs/util";
|
||||
import EntityIcon from "../components/EntityIcon.vue";
|
||||
@@ -324,6 +325,7 @@ export default class DIDView extends Vue {
|
||||
apiServer = "";
|
||||
claims: Array<GenericCredWrapper<GenericVerifiableCredential>> = [];
|
||||
contactFromDid?: Contact;
|
||||
|
||||
contactYaml = "";
|
||||
hitEnd = false;
|
||||
isLoading = false;
|
||||
@@ -722,18 +724,31 @@ export default class DIDView extends Vue {
|
||||
visibility: boolean,
|
||||
showSuccessAlert: boolean,
|
||||
) {
|
||||
// Update contact visibility using mixin method
|
||||
await this.$updateContact(contact.did, { seesMe: visibility });
|
||||
const result = await setVisibilityUtil(
|
||||
this.activeDid,
|
||||
this.apiServer,
|
||||
this.axios,
|
||||
contact,
|
||||
visibility,
|
||||
);
|
||||
|
||||
if (showSuccessAlert) {
|
||||
if (result.success) {
|
||||
if (showSuccessAlert) {
|
||||
const message =
|
||||
(contact.name || "That user") +
|
||||
" can " +
|
||||
(visibility ? "" : "not ") +
|
||||
"see your activity.";
|
||||
this.notify.success(message, TIMEOUTS.SHORT);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
logger.error("Got strange result from setting visibility:", result);
|
||||
const message =
|
||||
(contact.name || "That user") +
|
||||
" can " +
|
||||
(visibility ? "" : "not ") +
|
||||
"see your activity.";
|
||||
this.notify.success(message, TIMEOUTS.SHORT);
|
||||
(result.error as string) || "Could not set visibility on the server.";
|
||||
this.notify.error(message, TIMEOUTS.LONG);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user