forked from jsnbuchanan/crowd-funder-for-time-pwa
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;
|
$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 || "";
|
||||||
|
|||||||
@@ -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,18 +724,31 @@ 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 (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 =
|
const message =
|
||||||
(contact.name || "That user") +
|
(result.error as string) || "Could not set visibility on the server.";
|
||||||
" can " +
|
this.notify.error(message, TIMEOUTS.LONG);
|
||||||
(visibility ? "" : "not ") +
|
return false;
|
||||||
"see your activity.";
|
|
||||||
this.notify.success(message, TIMEOUTS.SHORT);
|
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user