Skip to content

Commit

Permalink
hotfix use "new" tag to display an article as New
Browse files Browse the repository at this point in the history
  • Loading branch information
danieleguido committed Feb 15, 2024
1 parent 48e6ee5 commit 544bd54
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
14 changes: 3 additions & 11 deletions src/components/Issue/IssueArticleGridItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@ import LangLink from '../LangLink'
import { Badge } from 'react-bootstrap'
import { useBoundingClientRect } from '../../hooks/graphics'
import { extractMetadataFromArticle, stripHtml } from '../../logic/api/metadata'
import { IsMobile } from '../../constants'
import { IsMobile, IsPrettyRecentTagName } from '../../constants'
import '../../styles/components/IssueArticleGridItem.scss'
import { ArrowRightCircle } from 'react-feather'
import IssueLabel from './IssueLabel'

const JustAddedTimeInterval = 3600000 * 24 * 240

const IssueArticleGridItem = ({
article = {},
isFake = false,
Expand All @@ -27,14 +25,8 @@ const IssueArticleGridItem = ({
const [{ width: size }, ref] = useBoundingClientRect()
const { title, keywords, excerpt, contributor } = extractMetadataFromArticle(article)
const { t } = useTranslation()
const isPrettyRecent = new Date() - new Date(article.publication_date) < JustAddedTimeInterval
console.debug(
'[IssueArticleGridItem]',
article.publication_date,
new Date() - new Date(article.publication_date),
JustAddedTimeInterval,
isPrettyRecent,
)
const isPrettyRecent = article.tags.some((d) => d.name === IsPrettyRecentTagName)

return (
<div
className={`IssueArticleGridItem ${isPrettyRecent ? 'just-added' : ''}`}
Expand Down
2 changes: 2 additions & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,3 +266,5 @@ export const AvailablesOrderByComparators = {
[OrderByPublicationDateAsc]: (a, b) => a.publication_date - b.publication_date,
[OrderByPublicationDateDesc]: (a, b) => b.publication_date - a.publication_date,
}

export const IsPrettyRecentTagName = 'new'

0 comments on commit 544bd54

Please sign in to comment.