Browse Source

show in description when recipient is a project (not just Anonymous)

pull/113/head
Trent Larson 8 months ago
parent
commit
0632fb9b39
  1. 4
      src/components/FeedFilters.vue
  2. 23
      src/libs/endorserServer.ts
  3. 52
      src/views/HomeView.vue

4
src/components/FeedFilters.vue

@ -11,7 +11,7 @@
@click="toggleHasVisibleDid()" @click="toggleHasVisibleDid()"
> >
<!-- label --> <!-- label -->
<div>Include Someone Visible to Me</div> <div>Include someone visible to me</div>
<!-- toggle --> <!-- toggle -->
<div class="relative ml-2"> <div class="relative ml-2">
<!-- input --> <!-- input -->
@ -41,7 +41,7 @@
" "
> >
<!-- label --> <!-- label -->
<div>Are Nearby</div> <div>Are nearby</div>
<!-- toggle --> <!-- toggle -->
<div v-if="hasSearchBox" class="relative ml-2"> <div v-if="hasSearchBox" class="relative ml-2">
<!-- input --> <!-- input -->

23
src/libs/endorserServer.ts

@ -112,6 +112,7 @@ export interface PlanSummaryRecord {
issuerDid: string; issuerDid: string;
locLat?: number; locLat?: number;
locLon?: number; locLon?: number;
name?: string;
startTime?: string; startTime?: string;
url?: string; url?: string;
} }
@ -415,8 +416,11 @@ export function didInfoForContact(
return myId return myId
? { displayName: "You (Alt ID)", known: true } ? { displayName: "You (Alt ID)", known: true }
: isHiddenDid(did) : isHiddenDid(did)
? { displayName: "Someone Outside Your Network", known: false } ? { displayName: "Someone Totally Outside Your View", known: false }
: { displayName: "Someone Outside Contacts", 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; return didInfoForContact(did, activeDid, contact, allMyDids).displayName;
} }
async function getHeaders(identity: IIdentifier) { async function getHeaders(identity: IIdentifier | null) {
const headers: RawAxiosRequestHeaders = { const headers: RawAxiosRequestHeaders = {
"Content-Type": "application/json", "Content-Type": "application/json",
}; };
@ -446,12 +450,21 @@ async function getHeaders(identity: IIdentifier) {
return headers; 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( export async function getPlanFromCache(
handleId: string, handleId: string | null,
identity: IIdentifier, identity: IIdentifier | null,
axios: Axios, axios: Axios,
apiServer: string, apiServer: string,
) { ) {
if (!handleId) {
return undefined;
}
let cred = planCache.get(handleId); let cred = planCache.get(handleId);
if (!cred) { if (!cred) {
const url = const url =

52
src/views/HomeView.vue

@ -200,20 +200,20 @@
</div> </div>
<div class="grid grid-cols-12"> <div class="grid grid-cols-12">
<span class="col-span-11 justify-self-start"> <span class="col-span-1 justify-self-start">
<span> <span>
<fa <fa
v-if="record.giver.known || record.receiver.known" v-if="record.giver.known || record.receiver.known"
icon="circle-user" icon="circle-user"
class="col-span-1 pt-1 pl-0 pr-3 text-slate-500" class="pt-1 text-slate-500"
/>
<fa
v-else
icon="gift"
class="col-span-1 pt-1 pl-3 pr-0 text-slate-500"
/> />
<fa v-else icon="gift" class="pt-1 pl-3 text-slate-500" />
</span>
</span> </span>
<span class="col-span-10 justify-self-stretch">
<span class="pl-2">
{{ giveDescription(record) }} {{ giveDescription(record) }}
</span>
<a @click="onClickLoadClaim(record.jwtId)"> <a @click="onClickLoadClaim(record.jwtId)">
<fa <fa
icon="file-lines" icon="file-lines"
@ -221,16 +221,15 @@
></fa> ></fa>
</a> </a>
</span> </span>
<span class="col-span-1 justify-self-end shrink"> <span class="col-span-1 justify-self-end">
<router-link <router-link
v-if="record.fulfillsPlanHandleId" v-if="record.fulfillsPlanHandleId"
:to=" :to="
'/project/' + '/project/' +
encodeURIComponent(record.fulfillsPlanHandleId) encodeURIComponent(record.fulfillsPlanHandleId)
" "
class="justify-end"
> >
<fa icon="hammer" class="ml-4 pl-2 text-blue-500"></fa> <fa icon="hammer" class="text-blue-500"></fa>
</router-link> </router-link>
</span> </span>
</div> </div>
@ -296,6 +295,7 @@ interface GiveRecordWithContactInfo extends GiveSummaryRecord {
known: boolean; known: boolean;
}; };
image: string; image: string;
recipientProjectName: string | undefined;
receiver: { receiver: {
displayName: string; displayName: string;
known: boolean; known: boolean;
@ -488,6 +488,14 @@ export default class HomeView extends Vue {
// recipient.did is for legacy data, before March 2023 // recipient.did is for legacy data, before March 2023
const recipientDid = const recipientDid =
claim.recipient?.identifier || (claim.recipient as any)?.did; // eslint-disable-line @typescript-eslint/no-explicit-any 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; let anyMatch = false;
if ( if (
this.isFeedFilteredByVisible && this.isFeedFilteredByVisible &&
@ -499,12 +507,6 @@ export default class HomeView extends Vue {
if (!anyMatch && this.isFeedFilteredByNearby) { if (!anyMatch && this.isFeedFilteredByNearby) {
// check if the associated project has a location inside user's search box // check if the associated project has a location inside user's search box
if (record.fulfillsPlanHandleId) { if (record.fulfillsPlanHandleId) {
const plan = await getPlanFromCache(
record.fulfillsPlanHandleId,
identity,
this.axios,
this.apiServer,
);
if (plan?.locLat && plan?.locLon) { if (plan?.locLat && plan?.locLon) {
if (this.latLongInAnySearchBox(plan.locLat, plan.locLon)) { if (this.latLongInAnySearchBox(plan.locLat, plan.locLon)) {
anyMatch = true; anyMatch = true;
@ -515,6 +517,7 @@ export default class HomeView extends Vue {
if (this.isAnyFeedFilterOn && !anyMatch) { if (this.isAnyFeedFilterOn && !anyMatch) {
return null; return null;
} }
return { return {
...record, ...record,
giver: didInfoForContact( giver: didInfoForContact(
@ -524,6 +527,7 @@ export default class HomeView extends Vue {
this.allMyDids, this.allMyDids,
), ),
image: claim.image, image: claim.image,
recipientProjectName: plan?.name,
receiver: didInfoForContact( receiver: didInfoForContact(
recipientDid, recipientDid,
this.activeDid, this.activeDid,
@ -632,12 +636,28 @@ export default class HomeView extends Vue {
return `${giverInfo.displayName} gave to ${recipientInfo.displayName}: ${gaveAmount}`; return `${giverInfo.displayName} gave to ${recipientInfo.displayName}: ${gaveAmount}`;
} else if (giverInfo.known) { } else if (giverInfo.known) {
// giver is named but recipient is not // 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})`; return `${giverInfo.displayName} gave: ${gaveAmount} (to ${recipientInfo.displayName})`;
} else if (recipientInfo.known) { } else if (recipientInfo.known) {
// recipient is named but giver is not // recipient is named but giver is not
return `${recipientInfo.displayName} received: ${gaveAmount} (from ${giverInfo.displayName})`; return `${recipientInfo.displayName} received: ${gaveAmount} (from ${giverInfo.displayName})`;
} else { } else {
// neither giver nor recipient are named // 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; let peopleInfo;
if (giverInfo.displayName === recipientInfo.displayName) { if (giverInfo.displayName === recipientInfo.displayName) {
peopleInfo = `between two who are ${giverInfo.displayName}`; peopleInfo = `between two who are ${giverInfo.displayName}`;

Loading…
Cancel
Save