forked from trent_larson/crowd-funder-for-time-pwa
add 'isRegistered' flag to encrypted contents in an onboarding meeting
This commit is contained in:
@@ -171,13 +171,13 @@ interface Member {
|
|||||||
admitted: boolean;
|
admitted: boolean;
|
||||||
content: string;
|
content: string;
|
||||||
memberId: number;
|
memberId: number;
|
||||||
registered: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface DecryptedMember {
|
interface DecryptedMember {
|
||||||
member: Member;
|
member: Member;
|
||||||
name: string;
|
name: string;
|
||||||
did: string;
|
did: string;
|
||||||
|
isRegistered: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@@ -258,6 +258,7 @@ export default class MembersList extends Vue {
|
|||||||
member: member,
|
member: member,
|
||||||
name: content.name,
|
name: content.name,
|
||||||
did: content.did,
|
did: content.did,
|
||||||
|
isRegistered: !!content.isRegistered,
|
||||||
});
|
});
|
||||||
if (isFirstEntry && content.did === this.activeDid) {
|
if (isFirstEntry && content.did === this.activeDid) {
|
||||||
this.isOrganizer = true;
|
this.isOrganizer = true;
|
||||||
@@ -293,7 +294,7 @@ export default class MembersList extends Vue {
|
|||||||
group: "alert",
|
group: "alert",
|
||||||
type: "info",
|
type: "info",
|
||||||
title: "Admission info",
|
title: "Admission info",
|
||||||
text: "This is to register people and admit them to the meeting. A '+' symbol means they are not yet admitted and you can register and admit them. A '-' means you can remove them, but they will stay registered.",
|
text: "This is to register people in Time Safari and to admit them to the meeting. A '+' symbol means they are not yet admitted and you can register and admit them. A '-' means you can remove them, but they will stay registered.",
|
||||||
},
|
},
|
||||||
10000,
|
10000,
|
||||||
);
|
);
|
||||||
@@ -331,67 +332,73 @@ export default class MembersList extends Vue {
|
|||||||
return this.contacts.find((contact) => contact.did === did);
|
return this.contacts.find((contact) => contact.did === did);
|
||||||
}
|
}
|
||||||
|
|
||||||
checkWhetherContactBeforeAdmitting(member: DecryptedMember) {
|
checkWhetherContactBeforeAdmitting(decrMember: DecryptedMember) {
|
||||||
const contact = this.getContactFor(member.did);
|
const contact = this.getContactFor(decrMember.did);
|
||||||
if (!member.member.admitted && !contact) {
|
if (!decrMember.member.admitted && !contact) {
|
||||||
// If not a contact, show confirmation dialog
|
// If not a contact, show confirmation dialog
|
||||||
this.$notify({
|
this.$notify(
|
||||||
group: "modal",
|
{
|
||||||
type: "confirm",
|
group: "modal",
|
||||||
title: "Add as Contact First?",
|
type: "confirm",
|
||||||
text: "This person is not in your contacts. Would you like to add them as a contact first?",
|
title: "Add as Contact First?",
|
||||||
yesText: "Add as Contact",
|
text: "This person is not in your contacts. Would you like to add them as a contact first?",
|
||||||
noText: "Skip Adding Contact",
|
yesText: "Add as Contact",
|
||||||
onYes: async () => {
|
noText: "Skip Adding Contact",
|
||||||
await this.addAsContact(member);
|
onYes: async () => {
|
||||||
// After adding as contact, proceed with admission
|
await this.addAsContact(decrMember);
|
||||||
await this.toggleAdmission(member);
|
// After adding as contact, proceed with admission
|
||||||
},
|
await this.toggleAdmission(decrMember);
|
||||||
onNo: async () => {
|
|
||||||
// If they choose not to add as contact, show second confirmation
|
|
||||||
this.$notify({
|
|
||||||
group: "modal",
|
|
||||||
type: "confirm",
|
|
||||||
title: "Continue Without Adding?",
|
|
||||||
text: "Are you sure you want to proceed with admission even though they are not a contact?",
|
|
||||||
yesText: "Continue",
|
|
||||||
onYes: async () => {
|
|
||||||
await this.toggleAdmission(member);
|
|
||||||
},
|
|
||||||
onCancel: async () => {
|
|
||||||
// Do nothing, effectively canceling the operation
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
-1,
|
onNo: async () => {
|
||||||
);
|
// If they choose not to add as contact, show second confirmation
|
||||||
},
|
this.$notify(
|
||||||
},
|
{
|
||||||
-1,
|
group: "modal",
|
||||||
);
|
type: "confirm",
|
||||||
|
title: "Continue Without Adding?",
|
||||||
|
text: "Are you sure you want to proceed with admission even though they are not a contact?",
|
||||||
|
yesText: "Continue",
|
||||||
|
onYes: async () => {
|
||||||
|
await this.toggleAdmission(decrMember);
|
||||||
|
},
|
||||||
|
onCancel: async () => {
|
||||||
|
// Do nothing, effectively canceling the operation
|
||||||
|
},
|
||||||
|
},
|
||||||
|
-1,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
-1,
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
// If already a contact, proceed directly with admission
|
// If already a contact, proceed directly with admission
|
||||||
this.toggleAdmission(member);
|
this.toggleAdmission(decrMember);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async toggleAdmission(member: DecryptedMember) {
|
async toggleAdmission(decrMember: DecryptedMember) {
|
||||||
try {
|
try {
|
||||||
const headers = await getHeaders(this.activeDid);
|
const headers = await getHeaders(this.activeDid);
|
||||||
await this.axios.put(
|
await this.axios.put(
|
||||||
`${this.apiServer}/api/partner/groupOnboardMember/${member.member.memberId}`,
|
`${this.apiServer}/api/partner/groupOnboardMember/${decrMember.member.memberId}`,
|
||||||
{ admitted: !member.member.admitted },
|
{ admitted: !decrMember.member.admitted },
|
||||||
{ headers },
|
{ headers },
|
||||||
);
|
);
|
||||||
// Update local state
|
// Update local state
|
||||||
member.member.admitted = !member.member.admitted;
|
decrMember.member.admitted = !decrMember.member.admitted;
|
||||||
|
|
||||||
const oldContact = this.getContactFor(member.did);
|
const oldContact = this.getContactFor(decrMember.did);
|
||||||
// if admitted, now register that user if they are not registered
|
// if admitted, now register that user if they are not registered
|
||||||
if (member.member.admitted && !oldContact?.registered) {
|
if (
|
||||||
|
decrMember.member.admitted &&
|
||||||
|
!decrMember.isRegistered &&
|
||||||
|
!oldContact?.registered
|
||||||
|
) {
|
||||||
const contactOldOrNew: Contact = oldContact || {
|
const contactOldOrNew: Contact = oldContact || {
|
||||||
did: member.did,
|
did: decrMember.did,
|
||||||
name: member.name,
|
name: decrMember.name,
|
||||||
}
|
};
|
||||||
try {
|
try {
|
||||||
const result = await register(
|
const result = await register(
|
||||||
this.activeDid,
|
this.activeDid,
|
||||||
@@ -400,9 +407,9 @@ export default class MembersList extends Vue {
|
|||||||
contactOldOrNew,
|
contactOldOrNew,
|
||||||
);
|
);
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
member.member.registered = true;
|
decrMember.isRegistered = true;
|
||||||
if (oldContact) {
|
if (oldContact) {
|
||||||
await db.contacts.update(member.did, { registered: true });
|
await db.contacts.update(decrMember.did, { registered: true });
|
||||||
oldContact.registered = true;
|
oldContact.registered = true;
|
||||||
}
|
}
|
||||||
this.$notify(
|
this.$notify(
|
||||||
@@ -417,16 +424,18 @@ export default class MembersList extends Vue {
|
|||||||
} else {
|
} else {
|
||||||
throw result;
|
throw result;
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
// registration failure is likely explained by a message from the server
|
// registration failure is likely explained by a message from the server
|
||||||
const additionalInfo = serverMessageForUser(error) || error?.error || "";
|
const additionalInfo =
|
||||||
|
serverMessageForUser(error) || error?.error || "";
|
||||||
this.$notify(
|
this.$notify(
|
||||||
{
|
{
|
||||||
group: "alert",
|
group: "alert",
|
||||||
type: "warning",
|
type: "warning",
|
||||||
title: "Registration failed",
|
title: "Registration failed",
|
||||||
text: "They were admitted to the meeting. However, registration failed. You can register them from the contacts screen. " +
|
text:
|
||||||
|
"They were admitted to the meeting. However, registration failed. You can register them from the contacts screen. " +
|
||||||
additionalInfo,
|
additionalInfo,
|
||||||
},
|
},
|
||||||
12000,
|
12000,
|
||||||
|
|||||||
@@ -126,6 +126,7 @@ export default class OnboardMeetingListView extends Vue {
|
|||||||
attendingMeeting: Meeting | null = null;
|
attendingMeeting: Meeting | null = null;
|
||||||
firstName = "";
|
firstName = "";
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
|
isRegistered = false;
|
||||||
meetings: Meeting[] = [];
|
meetings: Meeting[] = [];
|
||||||
password = "";
|
password = "";
|
||||||
selectedMeeting: Meeting | null = null;
|
selectedMeeting: Meeting | null = null;
|
||||||
@@ -136,6 +137,7 @@ export default class OnboardMeetingListView extends Vue {
|
|||||||
this.activeDid = settings.activeDid || "";
|
this.activeDid = settings.activeDid || "";
|
||||||
this.apiServer = settings.apiServer || "";
|
this.apiServer = settings.apiServer || "";
|
||||||
this.firstName = settings.firstName || "";
|
this.firstName = settings.firstName || "";
|
||||||
|
this.isRegistered = !!settings.isRegistered;
|
||||||
await this.fetchMeetings();
|
await this.fetchMeetings();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,6 +234,7 @@ export default class OnboardMeetingListView extends Vue {
|
|||||||
const memberData = {
|
const memberData = {
|
||||||
name: this.firstName,
|
name: this.firstName,
|
||||||
did: this.activeDid,
|
did: this.activeDid,
|
||||||
|
isRegistered: this.isRegistered,
|
||||||
};
|
};
|
||||||
const memberDataString = JSON.stringify(memberData);
|
const memberDataString = JSON.stringify(memberData);
|
||||||
const encryptedMemberData = await encryptMessage(
|
const encryptedMemberData = await encryptMessage(
|
||||||
|
|||||||
@@ -273,6 +273,7 @@ export default class OnboardMeetingView extends Vue {
|
|||||||
apiServer = "";
|
apiServer = "";
|
||||||
isDeleting = false;
|
isDeleting = false;
|
||||||
isLoading = true;
|
isLoading = true;
|
||||||
|
isRegistered = false;
|
||||||
showDeleteConfirm = false;
|
showDeleteConfirm = false;
|
||||||
fullName = "";
|
fullName = "";
|
||||||
get minDateTime() {
|
get minDateTime() {
|
||||||
@@ -286,6 +287,7 @@ export default class OnboardMeetingView extends Vue {
|
|||||||
this.activeDid = settings.activeDid || "";
|
this.activeDid = settings.activeDid || "";
|
||||||
this.apiServer = settings.apiServer || "";
|
this.apiServer = settings.apiServer || "";
|
||||||
this.fullName = settings.firstName || "";
|
this.fullName = settings.firstName || "";
|
||||||
|
this.isRegistered = !!settings.isRegistered;
|
||||||
|
|
||||||
await this.fetchCurrentMeeting();
|
await this.fetchCurrentMeeting();
|
||||||
this.isLoading = false;
|
this.isLoading = false;
|
||||||
@@ -409,6 +411,7 @@ export default class OnboardMeetingView extends Vue {
|
|||||||
const content = {
|
const content = {
|
||||||
name: this.newOrUpdatedMeeting.userFullName,
|
name: this.newOrUpdatedMeeting.userFullName,
|
||||||
did: this.activeDid,
|
did: this.activeDid,
|
||||||
|
isRegistered: this.isRegistered,
|
||||||
};
|
};
|
||||||
const encryptedContent = await encryptMessage(
|
const encryptedContent = await encryptMessage(
|
||||||
JSON.stringify(content),
|
JSON.stringify(content),
|
||||||
@@ -598,6 +601,7 @@ export default class OnboardMeetingView extends Vue {
|
|||||||
const content = {
|
const content = {
|
||||||
name: this.newOrUpdatedMeeting.userFullName,
|
name: this.newOrUpdatedMeeting.userFullName,
|
||||||
did: this.activeDid,
|
did: this.activeDid,
|
||||||
|
isRegistered: this.isRegistered,
|
||||||
};
|
};
|
||||||
const encryptedContent = await encryptMessage(
|
const encryptedContent = await encryptMessage(
|
||||||
JSON.stringify(content),
|
JSON.stringify(content),
|
||||||
|
|||||||
Reference in New Issue
Block a user