@ -27,7 +27,7 @@
< / span >
< / span >
< input
< input
type = "text"
type = "text"
placeholder = "DID, Name, Public Key"
placeholder = "DID, Name, Public Key (base 16 or 64) "
class = "block w-full rounded-l border border-r-0 border-slate-400 px-3 py-2"
class = "block w-full rounded-l border border-r-0 border-slate-400 px-3 py-2"
v - model = "contactInput"
v - model = "contactInput"
/ >
/ >
@ -110,6 +110,7 @@
< / div >
< / div >
< div id = "ContactActions" class = "flex gap-1.5 mt-2" >
< div id = "ContactActions" class = "flex gap-1.5 mt-2" >
< div v-if ="activeDid" >
< button
< button
v - if = "contact.seesMe"
v - if = "contact.seesMe"
class = "text-sm uppercase bg-slate-500 text-white px-2 py-1.5 rounded-md"
class = "text-sm uppercase bg-slate-500 text-white px-2 py-1.5 rounded-md"
@ -126,18 +127,18 @@
>
>
< fa icon = "eye-slash" class = "fa-fw" / >
< fa icon = "eye-slash" class = "fa-fw" / >
< / button >
< / button >
< button
< button
class = "text-sm uppercase bg-slate-500 text-white px-2 py-1.5 rounded-md"
class = "text-sm uppercase bg-slate-500 text-white px-2 py-1.5 rounded-md"
@ click = "checkVisibility(contact)"
@ click = "checkVisibility(contact)"
title = "Check Visibility"
title = "Check Visibility"
v - if = "activeDid"
>
>
< fa icon = "rotate" class = "fa-fw" / >
< fa icon = "rotate" class = "fa-fw" / >
< / button >
< / button >
< button
< button
@ click = "register(contact)"
@ click = "register(contact)"
class = "text-sm uppercase bg-slate-500 text-white ml-6 px-2 py-1.5 rounded-md"
class = "text-sm uppercase bg-slate-500 text-white ml-6 px-2 py-1.5 rounded-md"
v - if = "activeDid"
>
>
< fa
< fa
v - if = "contact.registered"
v - if = "contact.registered"
@ -152,6 +153,7 @@
title = "Registration Unknown"
title = "Registration Unknown"
/ >
/ >
< / button >
< / button >
< / div >
< button
< button
@ click = "deleteContact(contact)"
@ click = "deleteContact(contact)"
@ -263,6 +265,7 @@ import {
SimpleSigner ,
SimpleSigner ,
} from "@/libs/crypto" ;
} from "@/libs/crypto" ;
import {
import {
CONTACT_URL_PREFIX ,
GiveServerRecord ,
GiveServerRecord ,
GiveVerifiableCredential ,
GiveVerifiableCredential ,
RegisterVerifiableCredential ,
RegisterVerifiableCredential ,
@ -303,6 +306,7 @@ export default class ContactsView extends Vue {
givenToMeUnconfirmed : Record < string , number > = { } ;
givenToMeUnconfirmed : Record < string , number > = { } ;
hourDescriptionInput = "" ;
hourDescriptionInput = "" ;
hourInput = "0" ;
hourInput = "0" ;
isRegistered = false ;
showGiveNumbers = false ;
showGiveNumbers = false ;
showGiveTotals = true ;
showGiveTotals = true ;
showGiveConfirmed = true ;
showGiveConfirmed = true ;
@ -312,6 +316,7 @@ export default class ContactsView extends Vue {
const settings = ( await db . settings . get ( MASTER_SETTINGS_KEY ) ) as Settings ;
const settings = ( await db . settings . get ( MASTER_SETTINGS_KEY ) ) as Settings ;
this . activeDid = settings ? . activeDid || "" ;
this . activeDid = settings ? . activeDid || "" ;
this . apiServer = settings ? . apiServer || "" ;
this . apiServer = settings ? . apiServer || "" ;
this . isRegistered = ! ! settings ? . isRegistered ;
this . showGiveNumbers = ! ! settings ? . showContactGivesInline ;
this . showGiveNumbers = ! ! settings ? . showContactGivesInline ;
if ( this . showGiveNumbers ) {
if ( this . showGiveNumbers ) {
@ -475,6 +480,12 @@ export default class ContactsView extends Vue {
) ;
) ;
return ;
return ;
}
}
if ( this . contactInput . startsWith ( CONTACT_URL_PREFIX ) ) {
await this . newContactFromScan ( this . contactInput ) ;
return ;
}
let did = this . contactInput ;
let did = this . contactInput ;
let name , publicKeyBase64 ;
let name , publicKeyBase64 ;
const commaPos1 = this . contactInput . indexOf ( "," ) ;
const commaPos1 = this . contactInput . indexOf ( "," ) ;
@ -493,7 +504,7 @@ export default class ContactsView extends Vue {
publicKeyBase64 = Buffer . from ( publicKeyBase64 , "hex" ) . toString ( "base64" ) ;
publicKeyBase64 = Buffer . from ( publicKeyBase64 , "hex" ) . toString ( "base64" ) ;
}
}
const newContact = { did , name , publicKeyBase64 } ;
const newContact = { did , name , publicKeyBase64 } ;
return this . addContact ( newContact ) ;
await this . addContact ( newContact ) ;
}
}
async newContactFromScan ( url : string ) : Promise < void > {
async newContactFromScan ( url : string ) : Promise < void > {
@ -540,18 +551,25 @@ export default class ContactsView extends Vue {
( a : Contact , b ) => ( a . name || "" ) . localeCompare ( b . name || "" ) ,
( a : Contact , b ) => ( a . name || "" ) . localeCompare ( b . name || "" ) ,
allContacts ,
allContacts ,
) ;
) ;
let addedMessage ;
if ( this . activeDid ) {
this . setVisibility ( newContact , true , false ) ;
this . setVisibility ( newContact , true , false ) ;
addedMessage =
newContact . name +
" was added, and your activity is visible to them." ;
} else {
addedMessage = newContact . name + " was added." ;
}
this . $notify (
this . $notify (
{
{
group : "alert" ,
group : "alert" ,
type : "success" ,
type : "success" ,
title : "Contact Added" ,
title : "Contact Added" ,
text :
text : addedMessage ,
newContact . name +
" was added, and your activity is visible to them." ,
} ,
} ,
- 1 ,
5000 ,
) ;
) ;
if ( this . isRegistered ) {
/ / p u t t i n g t h i s l a s t s o t h a t i t s h o w s o n t h e t o p
/ / p u t t i n g t h i s l a s t s o t h a t i t s h o w s o n t h e t o p
this . $notify (
this . $notify (
{
{
@ -565,6 +583,7 @@ export default class ContactsView extends Vue {
} ,
} ,
- 1 ,
- 1 ,
) ;
) ;
}
} )
} )
. catch ( ( err ) => {
. catch ( ( err ) => {
console . error ( "Error when adding contact to storage:" , err ) ;
console . error ( "Error when adding contact to storage:" , err ) ;