@ -111,7 +111,7 @@
? 'bg-blue-600 text-white cursor-pointer'
: 'bg-slate-400 text-slate-200 cursor-not-allowed' ,
] "
@ click = "handleMainAction "
@ click = "processSelectedMembers "
>
{ { buttonText } }
< / button >
@ -145,7 +145,7 @@ import { Contact } from "@/db/tables/contacts";
export default class BulkMembersDialog extends Vue {
@ Prop ( { default : "" } ) activeDid ! : string ;
@ Prop ( { default : "" } ) apiServer ! : string ;
@ Prop ( { required : true } ) dialogType ! : "admit" | "visibility" ;
/ / i s O r g a n i z e r : t r u e = o r g a n i z e r m o d e ( a d m i t m e m b e r s ) , f a l s e = m e m b e r m o d e ( s e t v i s i b i l i t y )
@ Prop ( { required : true } ) isOrganizer ! : boolean ;
/ / V u e n o t i f i c a t i o n s y s t e m
@ -252,15 +252,7 @@ export default class BulkMembersDialog extends Vue {
return this . selectedMembers . includes ( memberDid ) ;
}
async handleMainAction ( ) {
if ( this . dialogType === "admit" ) {
await this . organizerAdmitAndAddWithVisibility ( ) ;
} else {
await this . memberAddContactWithVisibility ( ) ;
}
}
async organizerAdmitAndAddWithVisibility ( ) {
async processSelectedMembers ( ) {
try {
const selectedMembers : MemberData [ ] = this . membersData . filter ( ( member ) =>
this . selectedMembers . includes ( member . did ) ,
@ -275,16 +267,20 @@ export default class BulkMembersDialog extends Vue {
for ( const member of selectedMembers ) {
try {
/ / F i r s t , a d m i t t h e m e m b e r
/ / O r g a n i z e r m o d e : a d m i t a n d r e g i s t e r t h e m e m b e r f i r s t
if ( this . isOrganizer ) {
await this . admitMember ( member ) ;
/ / R e g i s t e r t h e m
await this . registerMember ( member ) ;
admittedCount ++ ;
}
/ / I f t h e y ' r e n o t a c o n t a c t y e t , a d d t h e m a s a c o n t a c t
if ( ! member . isContact ) {
await this . addAsContact ( member , true ) ;
/ / O r g a n i z e r m o d e : s e t i s R e g i s t e r e d t o t r u e , m e m b e r m o d e : u n d e f i n e d
await this . addAsContact (
member ,
this . isOrganizer ? true : undefined ,
) ;
contactAddedCount ++ ;
}
@ -299,6 +295,7 @@ export default class BulkMembersDialog extends Vue {
}
/ / S h o w s u c c e s s n o t i f i c a t i o n
if ( this . isOrganizer ) {
if ( admittedCount > 0 ) {
this . $notify (
{
@ -307,7 +304,7 @@ export default class BulkMembersDialog extends Vue {
title : "Members Admitted Successfully" ,
text : ` ${ admittedCount } member ${ admittedCount === 1 ? "" : "s" } admitted and registered ${ contactAddedCount === 0 ? "" : admittedCount === contactAddedCount ? " and" : ` , ${ contactAddedCount } ` } ${ contactAddedCount === 0 ? "" : ` added as contact ${ contactAddedCount === 1 ? "" : "s" } ` } . ` ,
} ,
10 000,
5 000 ,
) ;
}
if ( errors > 0 ) {
@ -321,66 +318,28 @@ export default class BulkMembersDialog extends Vue {
5000 ,
) ;
}
this . close ( notSelectedMembers . map ( ( member ) => member . did ) ) ;
} catch ( error ) {
/ / e s l i n t - d i s a b l e - n e x t - l i n e n o - c o n s o l e
console . error ( "Error admitting members:" , error ) ;
this . $notify (
{
group : "alert" ,
type : "danger" ,
title : "Error" ,
text : "Some errors occurred. Work with members individually below." ,
} ,
5000 ,
) ;
}
}
async memberAddContactWithVisibility ( ) {
try {
const selectedMembers : MemberData [ ] = this . membersData . filter ( ( member ) =>
this . selectedMembers . includes ( member . did ) ,
) ;
const notSelectedMembers : MemberData [ ] = this . membersData . filter (
( member ) => ! this . selectedMembers . includes ( member . did ) ,
) ;
let contactsAddedCount = 0 ;
for ( const member of selectedMembers ) {
try {
/ / I f t h e y ' r e n o t a c o n t a c t y e t , a d d t h e m a s a c o n t a c t f i r s t
if ( ! member . isContact ) {
await this . addAsContact ( member , undefined ) ;
contactsAddedCount ++ ;
}
/ / S e t t h e i r s e e s M e t o t r u e
await this . updateContactVisibility ( member . did , true ) ;
} catch ( error ) {
/ / e s l i n t - d i s a b l e - n e x t - l i n e n o - c o n s o l e
console . error ( ` Error processing member ${ member . did } : ` , error ) ;
/ / C o n t i n u e w i t h o t h e r m e m b e r s e v e n i f o n e f a i l s
}
}
/ / S h o w s u c c e s s n o t i f i c a t i o n
} else {
/ / M e m b e r m o d e : s h o w c o n t a c t s a d d e d n o t i f i c a t i o n
if ( contactAddedCount > 0 ) {
this . $notify (
{
group : "alert" ,
type : "success" ,
title : "Contacts Added Successfully" ,
text : ` ${ contacts AddedCount } member ${ contacts AddedCount === 1 ? "" : "s" } added as contact ${ contacts AddedCount === 1 ? "" : "s" } . ` ,
text : ` ${ contactAddedCount } member ${ contactAddedCount === 1 ? "" : "s" } added as contact ${ contactAddedCount === 1 ? "" : "s" } . ` ,
} ,
5000 ,
) ;
}
}
this . close ( notSelectedMembers . map ( ( member ) => member . did ) ) ;
} catch ( error ) {
/ / e s l i n t - d i s a b l e - n e x t - l i n e n o - c o n s o l e
console . error ( "Error adding contacts:" , error ) ;
console . error (
` Error ${ this . isOrganizer ? "admitting members" : "adding contacts" } : ` ,
error ,
) ;
this . $notify (
{
group : "alert" ,
@ -487,8 +446,8 @@ export default class BulkMembersDialog extends Vue {
}
showContactInfo ( ) {
const message =
this . dialogType === "admit"
/ / i s O r g a n i z e r : t r u e = a d m i t m o d e , f a l s e = v i s i b i l i t y m o d e
const message = this . isOrganizer
? "This user is already your contact, but they are not yet admitted to the meeting."
: "This user is already your contact, but your activities are not visible to them yet." ;