diff --git a/src/components/FeedFilters.vue b/src/components/FeedFilters.vue index a8b029af..e9cbac11 100644 --- a/src/components/FeedFilters.vue +++ b/src/components/FeedFilters.vue @@ -11,7 +11,7 @@ @click="toggleHasVisibleDid()" > -
Include Someone Visible to Me
+
Include someone visible to me
@@ -41,7 +41,7 @@ " > -
Are Nearby
+
Are nearby
diff --git a/src/libs/endorserServer.ts b/src/libs/endorserServer.ts index b1676e9f..7ac68bef 100644 --- a/src/libs/endorserServer.ts +++ b/src/libs/endorserServer.ts @@ -112,6 +112,7 @@ export interface PlanSummaryRecord { issuerDid: string; locLat?: number; locLon?: number; + name?: string; startTime?: string; url?: string; } @@ -415,8 +416,11 @@ export function didInfoForContact( return myId ? { displayName: "You (Alt ID)", known: true } : isHiddenDid(did) - ? { displayName: "Someone Outside Your Network", known: false } - : { displayName: "Someone Outside Contacts", known: false }; + ? { displayName: "Someone Totally Outside Your View", known: false } + : { + displayName: "Someone Visible But Outside Your Contact List", + known: false, + }; } } @@ -435,7 +439,7 @@ export function didInfo( return didInfoForContact(did, activeDid, contact, allMyDids).displayName; } -async function getHeaders(identity: IIdentifier) { +async function getHeaders(identity: IIdentifier | null) { const headers: RawAxiosRequestHeaders = { "Content-Type": "application/json", }; @@ -446,12 +450,21 @@ async function getHeaders(identity: IIdentifier) { return headers; } +/** + * @param handleId nullable -- which means that "undefined" will be returned + * @param identity nullable -- which means no private info will be returned + * @param axios + * @param apiServer + */ export async function getPlanFromCache( - handleId: string, - identity: IIdentifier, + handleId: string | null, + identity: IIdentifier | null, axios: Axios, apiServer: string, ) { + if (!handleId) { + return undefined; + } let cred = planCache.get(handleId); if (!cred) { const url = diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue index 57dca406..f94bf847 100644 --- a/src/views/HomeView.vue +++ b/src/views/HomeView.vue @@ -200,20 +200,20 @@
- + - + + + + + + {{ giveDescription(record) }} - {{ giveDescription(record) }} - + - +
@@ -296,6 +295,7 @@ interface GiveRecordWithContactInfo extends GiveSummaryRecord { known: boolean; }; image: string; + recipientProjectName: string | undefined; receiver: { displayName: string; known: boolean; @@ -488,6 +488,14 @@ export default class HomeView extends Vue { // recipient.did is for legacy data, before March 2023 const recipientDid = claim.recipient?.identifier || (claim.recipient as any)?.did; // eslint-disable-line @typescript-eslint/no-explicit-any + const plan = await getPlanFromCache( + record.fulfillsPlanHandleId, + identity, + this.axios, + this.apiServer, + ); + + // check if the record should be filtered out let anyMatch = false; if ( this.isFeedFilteredByVisible && @@ -499,12 +507,6 @@ export default class HomeView extends Vue { if (!anyMatch && this.isFeedFilteredByNearby) { // check if the associated project has a location inside user's search box if (record.fulfillsPlanHandleId) { - const plan = await getPlanFromCache( - record.fulfillsPlanHandleId, - identity, - this.axios, - this.apiServer, - ); if (plan?.locLat && plan?.locLon) { if (this.latLongInAnySearchBox(plan.locLat, plan.locLon)) { anyMatch = true; @@ -515,6 +517,7 @@ export default class HomeView extends Vue { if (this.isAnyFeedFilterOn && !anyMatch) { return null; } + return { ...record, giver: didInfoForContact( @@ -524,6 +527,7 @@ export default class HomeView extends Vue { this.allMyDids, ), image: claim.image, + recipientProjectName: plan?.name, receiver: didInfoForContact( recipientDid, this.activeDid, @@ -632,12 +636,28 @@ export default class HomeView extends Vue { return `${giverInfo.displayName} gave to ${recipientInfo.displayName}: ${gaveAmount}`; } else if (giverInfo.known) { // giver is named but recipient is not + + // show the project name if to one + if (giveRecord.recipientProjectName) { + // retrieve the project name + return `${giverInfo.displayName} gave: ${gaveAmount} (to the project ${giveRecord.recipientProjectName})`; + } + + // it's not to a project return `${giverInfo.displayName} gave: ${gaveAmount} (to ${recipientInfo.displayName})`; } else if (recipientInfo.known) { // recipient is named but giver is not return `${recipientInfo.displayName} received: ${gaveAmount} (from ${giverInfo.displayName})`; } else { // neither giver nor recipient are named + + // show the project name if to one + if (giveRecord.recipientProjectName) { + // retrieve the project name + return `${gaveAmount} (to the project ${giveRecord.recipientProjectName})`; + } + + // it's not to a project let peopleInfo; if (giverInfo.displayName === recipientInfo.displayName) { peopleInfo = `between two who are ${giverInfo.displayName}`;