forked from jsnbuchanan/crowd-funder-for-time-pwa
Replace hardcoded notification strings with standardized constants
- Replace literal strings with notification constants in ContactsView.vue: * "Got an error sending the invite." → NOTIFY_INVITE_ERROR.message * "Could not set visibility on the server." → NOTIFY_VISIBILITY_ERROR.message * "Unconfirmed Hours" → NOTIFY_UNCONFIRMED_HOURS.title - Remove unused NOTIFY_REGISTER_PROCESSING import - Remove unused NOTIFICATION_TIMEOUTS constant in ShareMyContactInfoView.vue - Fix unused parameter warnings in danger() and warning() methods - Resolve all notification-related linting errors
This commit is contained in:
@@ -305,7 +305,6 @@ import {
|
||||
NOTIFY_INVITE_ERROR,
|
||||
NOTIFY_ONBOARDING_CONFIRM,
|
||||
NOTIFY_REGISTER_NOT_AVAILABLE,
|
||||
NOTIFY_REGISTER_PROCESSING,
|
||||
NOTIFY_REGISTER_PERSON_SUCCESS,
|
||||
NOTIFY_REGISTER_PERSON_ERROR,
|
||||
NOTIFY_VISIBILITY_ERROR,
|
||||
@@ -390,10 +389,7 @@ export default class ContactsView extends Vue {
|
||||
|
||||
// Methods for template simplification
|
||||
showNotRegisteredWarning(): void {
|
||||
this.notify.warning(
|
||||
NOTIFY_REGISTER_NOT_AVAILABLE.message,
|
||||
TIMEOUTS.LONG,
|
||||
);
|
||||
this.notify.warning(NOTIFY_REGISTER_NOT_AVAILABLE.message, TIMEOUTS.LONG);
|
||||
}
|
||||
|
||||
toggleAllContacts(): void {
|
||||
@@ -434,7 +430,7 @@ export default class ContactsView extends Vue {
|
||||
|
||||
public async created() {
|
||||
this.notify = createNotifyHelpers(this.$notify);
|
||||
|
||||
|
||||
const settingsRow = await this.$getSettingsRow([
|
||||
"activeDid",
|
||||
"apiServer",
|
||||
@@ -490,10 +486,7 @@ export default class ContactsView extends Vue {
|
||||
const importedInviteJwt = this.$route.query["inviteJwt"] as string;
|
||||
if (importedInviteJwt === "") {
|
||||
// this happens when a platform (eg iOS) doesn't include anything after the "=" in a shared link.
|
||||
this.notify.error(
|
||||
NOTIFY_BLANK_INVITE.message,
|
||||
TIMEOUTS.VERY_LONG,
|
||||
);
|
||||
this.notify.error(NOTIFY_BLANK_INVITE.message, TIMEOUTS.VERY_LONG);
|
||||
} else if (importedInviteJwt) {
|
||||
// make sure user is created
|
||||
if (!this.activeDid) {
|
||||
@@ -560,7 +553,7 @@ export default class ContactsView extends Vue {
|
||||
response?: { data?: { error?: { message?: string } } };
|
||||
message?: string;
|
||||
};
|
||||
let message: string = "Got an error sending the invite.";
|
||||
let message: string = NOTIFY_INVITE_ERROR.message;
|
||||
if (err.response && err.response.data && err.response.data.error) {
|
||||
if (err.response.data.error.message) {
|
||||
message = err.response.data.error.message;
|
||||
@@ -573,10 +566,7 @@ export default class ContactsView extends Vue {
|
||||
} else if (typeof err.message === "string") {
|
||||
message = err.message;
|
||||
}
|
||||
this.notify.error(
|
||||
message,
|
||||
TIMEOUTS.MODAL,
|
||||
);
|
||||
this.notify.error(message, TIMEOUTS.MODAL);
|
||||
}
|
||||
// if we're here, they haven't redirected anywhere, so we'll redirect here without a query parameter
|
||||
this.$router.push({ path: "/contacts" });
|
||||
@@ -587,14 +577,10 @@ export default class ContactsView extends Vue {
|
||||
return (contactName || AppString.NO_CONTACT_NAME).replace(/\s/g, "\u00A0");
|
||||
}
|
||||
|
||||
private danger(message: string, title: string = "Error", timeout = 5000) {
|
||||
private danger(message: string, _title: string = "Error", timeout = 5000) {
|
||||
this.notify.error(message, timeout);
|
||||
}
|
||||
|
||||
private warning(message: string, title: string = "Error", timeout = 5000) {
|
||||
this.notify.warning(message, timeout);
|
||||
}
|
||||
|
||||
private showOnboardingInfo() {
|
||||
this.notify.confirm(
|
||||
NOTIFY_ONBOARDING_CONFIRM.message,
|
||||
@@ -703,10 +689,7 @@ export default class ContactsView extends Vue {
|
||||
} catch (error) {
|
||||
const fullError = "Error loading gives: " + errorStringForLog(error);
|
||||
logConsoleAndDb(fullError, true);
|
||||
this.notify.error(
|
||||
"Got an error loading your gives.",
|
||||
TIMEOUTS.STANDARD,
|
||||
);
|
||||
this.notify.error("Got an error loading your gives.", TIMEOUTS.STANDARD);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -929,10 +912,7 @@ export default class ContactsView extends Vue {
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
this.notify.success(
|
||||
addedMessage,
|
||||
TIMEOUTS.STANDARD,
|
||||
);
|
||||
this.notify.success(addedMessage, TIMEOUTS.STANDARD);
|
||||
})
|
||||
.catch((err) => {
|
||||
const fullError =
|
||||
@@ -1002,10 +982,7 @@ export default class ContactsView extends Vue {
|
||||
userMessage = error as string;
|
||||
}
|
||||
// Now set that error for the user to see.
|
||||
this.notify.error(
|
||||
userMessage,
|
||||
TIMEOUTS.MODAL,
|
||||
);
|
||||
this.notify.error(userMessage, TIMEOUTS.MODAL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1037,11 +1014,8 @@ export default class ContactsView extends Vue {
|
||||
result,
|
||||
);
|
||||
const message =
|
||||
(result.error as string) || "Could not set visibility on the server.";
|
||||
this.notify.error(
|
||||
message,
|
||||
TIMEOUTS.LONG,
|
||||
);
|
||||
(result.error as string) || NOTIFY_VISIBILITY_ERROR.message;
|
||||
this.notify.error(message, TIMEOUTS.LONG);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1067,7 +1041,7 @@ export default class ContactsView extends Vue {
|
||||
{
|
||||
group: "modal",
|
||||
type: "confirm",
|
||||
title: "Unconfirmed Hours",
|
||||
title: NOTIFY_UNCONFIRMED_HOURS.title,
|
||||
text: message,
|
||||
onNo: async () => {
|
||||
this.showGiftedDialog(giverDid, recipientDid);
|
||||
@@ -1223,10 +1197,7 @@ export default class ContactsView extends Vue {
|
||||
useClipboard()
|
||||
.copy(contactsJwtUrl)
|
||||
.then(() => {
|
||||
this.notify.copied(
|
||||
"contact link",
|
||||
TIMEOUTS.STANDARD,
|
||||
);
|
||||
this.notify.copied("contact link", TIMEOUTS.STANDARD);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user