Skip to content

Commit

Permalink
v4.4.3 - hotfix - use "new" tag to display an article as New
Browse files Browse the repository at this point in the history
Hotfix. use "new" tag to display an article as New. Merge pull request #613 from C2DH/develop
  • Loading branch information
danieleguido authored Feb 15, 2024
2 parents b46713f + 4714a13 commit c33707f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jdh",
"version": "4.4.2",
"version": "4.4.3",
"private": true,
"dependencies": {
"@auth0/auth0-react": "^1.1.0",
Expand Down
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 c33707f

Please sign in to comment.