forked from jsnbuchanan/crowd-funder-for-time-pwa
refactor: optimize success message logic in AdmitPendingMembersDialog
- Simplify success message generation using ternary operators - Remove visibilitySetCount due to its implied nature - Handle case when contactAddedCount is 0 by omitting contact-related text - Use more compact logic that only applies ternaries to variable parts - Maintain proper pluralization for both admitted members and contacts The message now shows: - "n member/s admitted." when no contacts added - "n member/s admitted and added as contact/s." when counts equal - "n member/s admitted, n added as contact/s." when counts differ
This commit is contained in:
@@ -218,7 +218,6 @@ export default class AdmitPendingMembersDialog extends Vue {
|
|||||||
|
|
||||||
let admittedCount = 0;
|
let admittedCount = 0;
|
||||||
let contactAddedCount = 0;
|
let contactAddedCount = 0;
|
||||||
let visibilitySetCount = 0;
|
|
||||||
|
|
||||||
for (const member of selectedMembers) {
|
for (const member of selectedMembers) {
|
||||||
try {
|
try {
|
||||||
@@ -234,7 +233,6 @@ export default class AdmitPendingMembersDialog extends Vue {
|
|||||||
|
|
||||||
// Set their seesMe to true
|
// Set their seesMe to true
|
||||||
await this.updateContactVisibility(member.did, true);
|
await this.updateContactVisibility(member.did, true);
|
||||||
visibilitySetCount++;
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.error(`Error processing member ${member.did}:`, error);
|
console.error(`Error processing member ${member.did}:`, error);
|
||||||
@@ -248,7 +246,7 @@ export default class AdmitPendingMembersDialog extends Vue {
|
|||||||
group: "alert",
|
group: "alert",
|
||||||
type: "success",
|
type: "success",
|
||||||
title: "Members Admitted Successfully",
|
title: "Members Admitted Successfully",
|
||||||
text: `Admitted ${admittedCount} member${admittedCount === 1 ? "" : "s"}, added ${contactAddedCount} as contact${contactAddedCount === 1 ? "" : "s"}, and set visibility for ${visibilitySetCount} member${visibilitySetCount === 1 ? "" : "s"}.`,
|
text: `${admittedCount} member${admittedCount === 1 ? "" : "s"} admitted${contactAddedCount === 0 ? "" : admittedCount === contactAddedCount ? " and" : `, ${contactAddedCount}`}${contactAddedCount === 0 ? "" : ` added as contact${contactAddedCount === 1 ? "" : "s"}`}.`,
|
||||||
},
|
},
|
||||||
10000,
|
10000,
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user