@ -298,6 +298,19 @@ import { logger } from "../utils/logger";
import { PlatformServiceMixin } from "@/utils/PlatformServiceMixin" ;
import { UserInfo , VerifiableCredentialClaim } from "../interfaces/common" ;
import { GiveSummaryRecord } from "../interfaces/records" ;
import { createNotifyHelpers , TIMEOUTS } from "@/utils/notify" ;
import {
NOTIFY_BLANK_INVITE ,
NOTIFY_INVITE_REGISTRATION_SUCCESS ,
NOTIFY_INVITE_ERROR ,
NOTIFY_ONBOARDING_CONFIRM ,
NOTIFY_REGISTER_NOT_AVAILABLE ,
NOTIFY_REGISTER_PROCESSING ,
NOTIFY_REGISTER_PERSON_SUCCESS ,
NOTIFY_REGISTER_PERSON_ERROR ,
NOTIFY_VISIBILITY_ERROR ,
NOTIFY_UNCONFIRMED_HOURS ,
} from "@/constants/notifications" ;
@ Component ( {
components : {
@ -315,6 +328,8 @@ export default class ContactsView extends Vue {
$route ! : RouteLocationNormalizedLoaded ;
$router ! : Router ;
notify ! : ReturnType < typeof createNotifyHelpers > ;
activeDid = "" ;
apiServer = "" ;
contacts : Array < Contact > = [ ] ;
@ -375,9 +390,9 @@ export default class ContactsView extends Vue {
/ / M e t h o d s f o r t e m p l a t e s i m p l i f i c a t i o n
showNotRegisteredWarning ( ) : void {
this . warning (
"You must get registered before you can create invites." ,
"Not Registered" ,
this . notify . warning (
NOTIFY_REGISTER_NOT_AVAILABLE . message ,
TIMEOUTS . LONG ,
) ;
}
@ -418,6 +433,8 @@ export default class ContactsView extends Vue {
}
public async created ( ) {
this . notify = createNotifyHelpers ( this . $notify ) ;
const settingsRow = await this . $getSettingsRow ( [
"activeDid" ,
"apiServer" ,
@ -473,14 +490,9 @@ export default class ContactsView extends Vue {
const importedInviteJwt = this . $route . query [ "inviteJwt" ] as string ;
if ( importedInviteJwt === "" ) {
/ / t h i s h a p p e n s w h e n a p l a t f o r m ( e g i O S ) d o e s n ' t i n c l u d e a n y t h i n g a f t e r t h e " = " i n a s h a r e d l i n k .
this . $notify (
{
group : "alert" ,
type : "danger" ,
title : "Blank Invite" ,
text : "The invite was not included, which can happen when your iOS device cuts off the link. Try pasting the full link into a browser." ,
} ,
7000 ,
this . notify . error (
NOTIFY_BLANK_INVITE . message ,
TIMEOUTS . VERY_LONG ,
) ;
} else if ( importedInviteJwt ) {
/ / m a k e s u r e u s e r i s c r e a t e d
@ -500,14 +512,9 @@ export default class ContactsView extends Vue {
}
await this . $updateSettings ( { isRegistered : true } , this . activeDid ) ;
this . isRegistered = true ;
this . $notify (
{
group : "alert" ,
type : "success" ,
title : "Registered" ,
text : "You are now registered." ,
} ,
3000 ,
this . notify . success (
NOTIFY_INVITE_REGISTRATION_SUCCESS . message ,
TIMEOUTS . STANDARD ,
) ;
/ / w a i t f o r a s e c o n d b e f o r e c o n t i n u i n g s o t h e y s e e t h e r e g i s t r a t i o n m e s s a g e
@ -566,14 +573,9 @@ export default class ContactsView extends Vue {
} else if ( typeof err . message === "string" ) {
message = err . message ;
}
this . $notify (
{
group : "alert" ,
type : "danger" ,
title : "Error with Invite" ,
text : message ,
} ,
- 1 ,
this . notify . error (
message ,
TIMEOUTS . MODAL ,
) ;
}
/ / i f w e ' r e h e r e , t h e y h a v e n ' t r e d i r e c t e d a n y w h e r e , s o w e ' l l r e d i r e c t h e r e w i t h o u t a q u e r y p a r a m e t e r
@ -586,41 +588,20 @@ export default class ContactsView extends Vue {
}
private danger ( message : string , title : string = "Error" , timeout = 5000 ) {
this . $notify (
{
group : "alert" ,
type : "danger" ,
title : title ,
text : message ,
} ,
timeout ,
) ;
this . notify . error ( message , timeout ) ;
}
private warning ( message : string , title : string = "Error" , timeout = 5000 ) {
this . $notify (
{
group : "alert" ,
type : "warning" ,
title : title ,
text : message ,
} ,
timeout ,
) ;
this . notify . warning ( message , timeout ) ;
}
private showOnboardingInfo ( ) {
this . $notify (
{
group : "modal" ,
type : "confirm" ,
title : "They're Added To Your List" ,
text : "Would you like to go to the main page now?" ,
onYes : async ( ) => {
this . $router . push ( { name : "home" } ) ;
} ,
this . notify . confirm (
NOTIFY_ONBOARDING_CONFIRM . message ,
async ( ) => {
this . $router . push ( { name : "home" } ) ;
} ,
- 1 ,
TIMEOUTS . MODAL ,
) ;
}
@ -669,17 +650,9 @@ export default class ContactsView extends Vue {
resp . status ,
resp . data ,
) ;
this . $notify (
{
group : "alert" ,
type : "danger" ,
title : "Retrieval Error" ,
text :
"Got an error retrieving your " +
( useRecipient ? "given" : "received" ) +
" data from the server." ,
} ,
3000 ,
this . notify . error (
` Got an error retrieving your ${ useRecipient ? "given" : "received" } data from the server. ` ,
TIMEOUTS . STANDARD ,
) ;
}
} ;
@ -730,14 +703,9 @@ export default class ContactsView extends Vue {
} catch ( error ) {
const fullError = "Error loading gives: " + errorStringForLog ( error ) ;
logConsoleAndDb ( fullError , true ) ;
this . $notify (
{
group : "alert" ,
type : "danger" ,
title : "Load Error" ,
text : "Got an error loading your gives." ,
} ,
3000 ,
this . notify . error (
"Got an error loading your gives." ,
TIMEOUTS . STANDARD ,
) ;
}
}
@ -806,14 +774,9 @@ export default class ContactsView extends Vue {
}
try {
await Promise . all ( lineAdded ) ;
this . $notify (
{
group : "alert" ,
type : "success" ,
title : "Contacts Added" ,
text : "Each contact was added. Nothing was sent to the server." ,
} ,
3000 , / / k e e p i n g i t u p s o t h a t t h e " v i s i b i l i t y " m e s s a g e i s s e e n
this . notify . success (
"Each contact was added. Nothing was sent to the server." ,
TIMEOUTS . STANDARD , / / k e e p i n g i t u p s o t h a t t h e " v i s i b i l i t y " m e s s a g e i s s e e n
) ;
} catch ( e ) {
const fullError =
@ -961,19 +924,14 @@ export default class ContactsView extends Vue {
} ,
promptToStopAsking : true ,
} ,
- 1 ,
TIMEOUTS . MODAL ,
) ;
} , 1000 ) ;
}
}
this . $notify (
{
group : "alert" ,
type : "success" ,
title : "Contact Added" ,
text : addedMessage ,
} ,
3000 ,
this . notify . success (
addedMessage ,
TIMEOUTS . STANDARD ,
) ;
} )
. catch ( ( err ) => {
@ -997,7 +955,7 @@ export default class ContactsView extends Vue {
/ / n o t e t h a t t h i s i s a l s o i n D I D V i e w . v u e
private async register ( contact : Contact ) {
this . $notify ( { group : "alert" , type : "toast" , title : "Sent..." } , 1000 ) ;
this . notify . sent ( TIMEOUTS . BRIEF ) ;
try {
const regResult = await register (
@ -1010,27 +968,14 @@ export default class ContactsView extends Vue {
contact . registered = true ;
await this . $updateContact ( contact . did , { registered : true } ) ;
this . $notify (
{
group : "alert" ,
type : "success" ,
title : "Registration Success" ,
text :
( contact . name || "That unnamed person" ) + " has been registered." ,
} ,
3000 ,
this . notify . success (
` ${ contact . name || "That unnamed person" } ${ NOTIFY_REGISTER_PERSON_SUCCESS . message } ` ,
TIMEOUTS . STANDARD ,
) ;
} else {
this . $notify (
{
group : "alert" ,
type : "danger" ,
title : "Registration Error" ,
text :
( regResult . error as string ) ||
"Something went wrong during registration." ,
} ,
- 1 ,
this . notify . error (
( regResult . error as string ) || NOTIFY_REGISTER_PERSON_ERROR . message ,
TIMEOUTS . MODAL ,
) ;
}
} catch ( error ) {
@ -1057,14 +1002,9 @@ export default class ContactsView extends Vue {
userMessage = error as string ;
}
/ / N o w s e t t h a t e r r o r f o r t h e u s e r t o s e e .
this . $notify (
{
group : "alert" ,
type : "danger" ,
title : "Registration Error" ,
text : userMessage ,
} ,
- 1 ,
this . notify . error (
userMessage ,
TIMEOUTS . MODAL ,
) ;
}
}
@ -1085,18 +1025,9 @@ export default class ContactsView extends Vue {
if ( result . success ) {
/ / c o n t a c t . s e e s M e = v i s i b i l i t y ; / / w h y d o e s n ' t i t a f f e c t t h e U I f r o m h e r e ?
if ( showSuccessAlert ) {
this . $notify (
{
group : "alert" ,
type : "success" ,
title : "Visibility Set" ,
text :
( contact . name || "That user" ) +
" can " +
( visibility ? "" : "not " ) +
"see your activity." ,
} ,
3000 ,
this . notify . success (
` ${ contact . name || "That user" } can ${ visibility ? "" : "not " } see your activity. ` ,
TIMEOUTS . STANDARD ,
) ;
}
return true ;
@ -1107,14 +1038,9 @@ export default class ContactsView extends Vue {
) ;
const message =
( result . error as string ) || "Could not set visibility on the server." ;
this . $notify (
{
group : "alert" ,
type : "danger" ,
title : "Error Setting Visibility" ,
text : message ,
} ,
5000 ,
this . notify . error (
message ,
TIMEOUTS . LONG ,
) ;
return false ;
}
@ -1141,7 +1067,7 @@ export default class ContactsView extends Vue {
{
group : "modal" ,
type : "confirm" ,
title : "Delete " ,
title : "Unconfirmed Hours " ,
text : message ,
onNo : async ( ) => {
this . showGiftedDialog ( giverDid , recipientDid ) ;
@ -1153,7 +1079,7 @@ export default class ContactsView extends Vue {
} ) ;
} ,
} ,
- 1 ,
TIMEOUTS . MODAL ,
) ;
} else {
this . showGiftedDialog ( giverDid , recipientDid ) ;
@ -1222,14 +1148,9 @@ export default class ContactsView extends Vue {
const fullError =
"Error updating contact-amounts setting: " + errorStringForLog ( err ) ;
logConsoleAndDb ( fullError , true ) ;
this . $notify (
{
group : "alert" ,
type : "danger" ,
title : "Error Updating Contact Setting" ,
text : "The setting may not have saved. Try again, maybe after restarting the app." ,
} ,
5000 ,
this . notify . error (
"The setting may not have saved. Try again, maybe after restarting the app." ,
TIMEOUTS . LONG ,
) ;
}
this . showGiveNumbers = newShowValue ;
@ -1302,27 +1223,17 @@ export default class ContactsView extends Vue {
useClipboard ( )
. copy ( contactsJwtUrl )
. then ( ( ) => {
this . $notify (
{
group : "alert" ,
type : "info" ,
title : "Copied" ,
text : "The link for those contacts is now in the clipboard." ,
} ,
3000 ,
this . notify . copied (
"contact link" ,
TIMEOUTS . STANDARD ,
) ;
} ) ;
}
private showCopySelectionsInfo ( ) {
this . $notify (
{
group : "alert" ,
type : "info" ,
title : "Copying Contacts" ,
text : "Contact info will include name, ID, profile image, and public key." ,
} ,
5000 ,
this . notify . info (
"Contact info will include name, ID, profile image, and public key." ,
TIMEOUTS . LONG ,
) ;
}
@ -1366,7 +1277,7 @@ export default class ContactsView extends Vue {
} ,
noText : "Join Existing Meeting" ,
} ,
- 1 ,
TIMEOUTS . MODAL ,
) ;
}
} catch ( error ) {