@ -54,6 +54,15 @@
Refresh
Refresh
< span class = "text-xs" > ( { { countdownTimer } } s ) < / span >
< span class = "text-xs" > ( { { countdownTimer } } s ) < / span >
< / button >
< / button >
< button
v - if = "getPendingMembersCount() > 0"
class = "text-sm bg-gradient-to-b from-blue-100 to-blue-200 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.2)] text-blue-800 px-3 py-1.5 rounded-md"
@ click = "showAdmitAllPendingDialog"
>
< font -awesome icon = "circle-plus" class = "text-blue-500" / >
Admit Pending
< / button >
< / div >
< / div >
< ul
< ul
v - if = "membersToShow().length > 0"
v - if = "membersToShow().length > 0"
@ -86,8 +95,8 @@
/ >
/ >
< font -awesome
< font -awesome
v - if = "!member.member.admitted"
v - if = "!member.member.admitted"
icon = "spinner "
icon = "hourglass-half "
class = "fa-fw fa-spin-pulse text-slate-400"
class = "fa-fw text-slate-400"
/ >
/ >
{ { member . name || unnamedMember } }
{ { member . name || unnamedMember } }
< / h3 >
< / h3 >
@ -205,6 +214,7 @@ import { createNotifyHelpers, TIMEOUTS } from "@/utils/notify";
import {
import {
NOTIFY_ADD_CONTACT_FIRST ,
NOTIFY_ADD_CONTACT_FIRST ,
NOTIFY_CONTINUE_WITHOUT_ADDING ,
NOTIFY_CONTINUE_WITHOUT_ADDING ,
NOTIFY_ADMIT_ALL_PENDING ,
} from "@/constants/notifications" ;
} from "@/constants/notifications" ;
import { SOMEONE_UNNAMED } from "@/constants/entities" ;
import { SOMEONE_UNNAMED } from "@/constants/entities" ;
import SetBulkVisibilityDialog from "./SetBulkVisibilityDialog.vue" ;
import SetBulkVisibilityDialog from "./SetBulkVisibilityDialog.vue" ;
@ -744,6 +754,114 @@ export default class MembersList extends Vue {
this . startAutoRefresh ( ) ;
this . startAutoRefresh ( ) ;
}
}
/ * *
* Get count of pending ( non - admitted ) members
* /
getPendingMembersCount ( ) : number {
return this . decryptedMembers . filter (
( member ) => ! member . member . admitted && member . did !== this . activeDid ,
) . length ;
}
/ * *
* Get list of pending members
* /
getPendingMembers ( ) : DecryptedMember [ ] {
return this . decryptedMembers . filter (
( member ) => ! member . member . admitted && member . did !== this . activeDid ,
) ;
}
/ * *
* Show the admit all pending members dialog
* /
showAdmitAllPendingDialog ( ) {
const pendingCount = this . getPendingMembersCount ( ) ;
if ( pendingCount === 0 ) {
this . notify . info (
"There are no pending members to admit." ,
TIMEOUTS . STANDARD ,
) ;
return ;
}
/ / P a u s e a u t o - r e f r e s h w h e n d i a l o g o p e n s
this . stopAutoRefresh ( ) ;
const dialogText = NOTIFY_ADMIT_ALL_PENDING . text . replace (
"{count}" ,
pendingCount . toString ( ) ,
) ;
this . $notify (
{
group : "modal" ,
type : "confirm" ,
title : NOTIFY_ADMIT_ALL_PENDING . title ,
text : dialogText ,
yesText : NOTIFY_ADMIT_ALL_PENDING . yesText ,
noText : NOTIFY_ADMIT_ALL_PENDING . noText ,
onYes : async ( ) => {
await this . admitAllPendingMembers ( true ) ; / / t r u e = a d d t o c o n t a c t s
/ / R e s u m e a u t o - r e f r e s h a f t e r a c t i o n
this . startAutoRefresh ( ) ;
} ,
onNo : async ( ) => {
await this . admitAllPendingMembers ( false ) ; / / f a l s e = d o n ' t a d d t o c o n t a c t s
/ / R e s u m e a u t o - r e f r e s h a f t e r a c t i o n
this . startAutoRefresh ( ) ;
} ,
onCancel : async ( ) => {
/ / D o n o t h i n g - u s e r c a n c e l l e d
/ / R e s u m e a u t o - r e f r e s h a f t e r c a n c e l l a t i o n
this . startAutoRefresh ( ) ;
} ,
} ,
TIMEOUTS . MODAL ,
) ;
}
/ * *
* Admit all pending members with optional contact addition
* /
async admitAllPendingMembers ( addToContacts : boolean ) {
const pendingMembers = this . getPendingMembers ( ) ;
if ( pendingMembers . length === 0 ) {
return ;
}
try {
/ / P r o c e s s e a c h p e n d i n g m e m b e r
for ( const member of pendingMembers ) {
/ / A d d t o c o n t a c t s i f r e q u e s t e d a n d n o t a l r e a d y a c o n t a c t
if ( addToContacts && ! this . getContactFor ( member . did ) ) {
await this . addAsContact ( member ) ;
}
/ / A d m i t t h e m e m b e r
await this . toggleAdmission ( member ) ;
}
/ / S h o w s u c c e s s m e s s a g e
const contactMessage = addToContacts ? " and added to your contacts" : "" ;
this . notify . success (
` All ${ pendingMembers . length } pending members have been admitted ${ contactMessage } . ` ,
TIMEOUTS . STANDARD ,
) ;
} catch ( error ) {
this . $logAndConsole (
"Error admitting all pending members: " + errorStringForLog ( error ) ,
true ,
) ;
this . notify . error (
"Failed to admit some members. Please try again." ,
TIMEOUTS . LONG ,
) ;
}
}
beforeDestroy ( ) {
beforeDestroy ( ) {
this . stopAutoRefresh ( ) ;
this . stopAutoRefresh ( ) ;
}
}