diff --git a/src/libs/endorserServer.ts b/src/libs/endorserServer.ts index 45ad00a..55756e6 100644 --- a/src/libs/endorserServer.ts +++ b/src/libs/endorserServer.ts @@ -352,32 +352,65 @@ export function removeVisibleToDids(input: any): any { } } -/** - always returns text, maybe UNNAMED_VISIBLE or UNKNOWN_ENTITY - - Similar logic is found in endorser-mobile. - **/ -export function didInfo( +export function contactForDid( did: string | undefined, - activeDid: string | undefined, - allMyDids: string[], contacts: Contact[], -): string { - if (!did) return "Someone Anonymous"; +): Contact | undefined { + return isEmptyOrHiddenDid(did) + ? undefined + : R.find((c) => c.did === did, contacts); +} - const contact = R.find((c) => c.did === did, contacts); +/** + * + * Similar logic is found in endorser-mobile. + * + * @param did + * @param activeDid + * @param contact + * @param allMyDids + * @return { known: boolean, displayName: string } where known is true if the display name is some easily-recogizable name, false if it's a generic name like "Someone Anonymous" + */ +export function didInfoForContact( + did: string | undefined, + activeDid: string | undefined, + contact?: Contact, + allMyDids: string[] = [], + // eslint-disable-next-line @typescript-eslint/no-explicit-any +): { known: boolean; displayName: string } { + if (!did) return { displayName: "Someone Anonymous", known: false }; if (contact) { - return contact.name || "Contact With No Name"; + return { + displayName: contact.name || "Contact With No Name", + known: !!contact.name, + }; + } else if (did === activeDid) { + return { displayName: "You", known: true }; } else { const myId = R.find(R.equals(did), allMyDids); return myId - ? `You${myId !== activeDid ? " (Alt ID)" : ""}` + ? { displayName: "You (Alt ID)", known: true } : isHiddenDid(did) - ? "Someone Outside Your Network" - : "Someone Outside Contacts"; + ? { displayName: "Someone Outside Your Network", known: false } + : { displayName: "Someone Outside Contacts", known: false }; } } +/** + always returns text, maybe something like "unnamed" or "unknown" + + Now that we're using more informational didInfoForContact under the covers, we might want to consolidate. + **/ +export function didInfo( + did: string | undefined, + activeDid: string | undefined, + allMyDids: string[], + contacts: Contact[], +): string { + const contact = contactForDid(did, contacts); + return didInfoForContact(did, activeDid, contact, allMyDids).displayName; +} + /** * For result, see https://api.endorser.ch/api-docs/#/claims/post_api_v2_claim * diff --git a/src/router/index.ts b/src/router/index.ts index 0e653ad..68da028 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -28,12 +28,6 @@ const enterOrStart = async ( }; const routes: Array = [ - { - path: "/", - name: "home", - component: () => - import(/* webpackChunkName: "home" */ "../views/HomeView.vue"), - }, { path: "/account", name: "account", @@ -96,6 +90,12 @@ const routes: Array = [ component: () => import(/* webpackChunkName: "help" */ "../views/HelpView.vue"), }, + { + path: "/", + name: "home", + component: () => + import(/* webpackChunkName: "home" */ "../views/HomeView.vue"), + }, { path: "/help-notifications", name: "help-notifications", diff --git a/src/views/AccountViewView.vue b/src/views/AccountViewView.vue index 47633a5..864db7c 100644 --- a/src/views/AccountViewView.vue +++ b/src/views/AccountViewView.vue @@ -1,5 +1,5 @@