Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions components/Funding/ActivityCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const DOC_ACTION_LABELS: Record<string, string> = {
PREREGISTRATION: 'submitted proposal',
POST: 'posted discussion',
PAPER: 'published preprint',
USDFUNDRAISECONTRIBUTION: 'contributed to',
};

const CONTENT_TYPE_MAP: Record<string, ContentType> = {
Expand All @@ -47,6 +48,14 @@ function getActionLabel(entry: FeedEntry): string {
return COMMENT_ACTION_LABELS[comment?.commentType] || 'commented on';
}
if (entry.contentType === 'BOUNTY') return 'contributed to';

if (entry.contentType === 'POST') {
const post = entry.content as FeedPostContent;
if (post.postType === 'USDFUNDRAISECONTRIBUTION') {
return DOC_ACTION_LABELS['USDFUNDRAISECONTRIBUTION'] || 'contributed to';
}
}

return DOC_ACTION_LABELS[entry.contentType] || 'contributed';
}

Expand All @@ -66,6 +75,24 @@ function getEntryMeta(entry: FeedEntry) {
}

const titled = content as FeedPostContent | FeedPaperContent | FeedGrantContent;

if (entry.contentType === 'POST') {
const post = content as FeedPostContent;
if (post.postType === 'USDFUNDRAISECONTRIBUTION' && post.fundraise) {
return {
title: post.fundraise.postTitle || titled.title,
author,
href: post.fundraise.postId && post.fundraise.postSlug
? buildWorkUrl({
id: post.fundraise.postId,
slug: post.fundraise.postSlug,
contentType: 'preregistration',
})
: undefined,
};
}
}

return {
title: titled.title,
author,
Expand Down
18 changes: 14 additions & 4 deletions types/feed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -864,11 +864,21 @@ export const transformFeedEntry = (feedEntry: RawApiFeedEntry): FeedEntry => {
try {
// Extract the necessary data from content_object
const isPreregistration = content_object.type === 'PREREGISTRATION';
const isDAFContribution = content_object.type === 'USDFUNDRAISECONTRIBUTION';

if (isPreregistration) {
contentType = 'PREREGISTRATION';
}

// For DAF contributions, use fundraise post title/image if available
const title = isDAFContribution && content_object.fundraise?.post_title
? content_object.fundraise.post_title
: content_object.title || '';

const previewImage = isDAFContribution && content_object.fundraise?.post_image
? content_object.fundraise.post_image
: content_object.image_url || '';

// Create a FeedPostEntry object
const postEntry: FeedPostContent = {
id: content_object.id,
Expand All @@ -878,8 +888,8 @@ export const transformFeedEntry = (feedEntry: RawApiFeedEntry): FeedEntry => {
createdDate: action_date || content_object.created_date,
textPreview: content_object.renderable_text || '',
slug: content_object.slug || '',
title: stripHtml(content_object.title || ''),
previewImage: content_object.image_url || '',
title: stripHtml(title),
previewImage,
authors:
content_object.authors && content_object.authors.length > 0
? content_object.authors.map(transformAuthorProfile)
Expand Down Expand Up @@ -915,8 +925,8 @@ export const transformFeedEntry = (feedEntry: RawApiFeedEntry): FeedEntry => {
: [],
};

// Add fundraise data if it's a PREREGISTRATION and has fundraise data
if (isPreregistration && content_object.fundraise) {
// Add fundraise data if it's a PREREGISTRATION or DAF contribution with fundraise data
if ((isPreregistration || isDAFContribution) && content_object.fundraise) {
try {
postEntry.fundraise = transformFundraise(content_object.fundraise);
} catch (fundraiseError) {
Expand Down