Skip to content

Conversation

@syqs
Copy link

@syqs syqs commented Oct 22, 2025

Issue: ResearchHub/issues#599

  • Adds additional logic to display RPF icon in the search suggestions based on document_type
  • Adds document_type mappings in the utils/contentTypeMapping.ts

Before

Screen Shot 2025-10-22 at 5 29 09 PM

After

Screen Shot 2025-10-22 at 5 27 28 PM

@syqs syqs requested a review from a team as a code owner October 22, 2025 22:30
@vercel
Copy link

vercel bot commented Oct 22, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
web Ready Ready Preview Comment Oct 27, 2025 6:53pm

*/
export function getContentTypeFromDocumentType(
documentType: string
): 'paper' | 'post' | 'funding_request' | 'preregistration' {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to do cleanup because funding_request and preregistration mean the same thing.

I feel like Nick created this function already in one of his PRs. @nicktytarenko - can you confirm?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • if i am not mistaken funding_request is the same thing as grant in the web app world.. you can see the evidence in this historical mocked data: https://github.com/ResearchHub/web/blob/main/store/grantStore.ts#L27
    there was naming changes to this entity. so, it's probably still confused in the web app 🤯

  • actually we do not have a function to convert API contentType to the App type, we do it on a fly when we transform the work details response in the types/work.ts.

  • if you pull the latest main into this branch you will see the method for converting WebApptypeToAPIType. it's like the opposite of this

cc @yattias

BOUNTY: 'post',
HYPOTHESIS: 'post',
};
return contentTypeMap[documentType] || 'post';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather we not use post as default. We can return null as well if no appropriate match is found

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm.. if we switch it to null that might potentially break few things and would require a bigger refactor of the codebase to incorporate the new approach which is why it was defaulting to post in the first place.

Pros:

  • We could identify when unknown document types appear

Cons:

  • Requires defensive coding: Every caller would need to handle null explicitly
  • Risk of broken links: Without proper null handling, URLs could break or redirect incorrectly

My recommendation is to keep the post as default and add a warning log. Your call but refactoring would prolly require its own PR and potentially be changing many files.

@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants