From 76304f37e07897c7c3f6087c5aa221bc66977a68 Mon Sep 17 00:00:00 2001 From: rleed Date: Wed, 18 Oct 2023 09:01:10 -0300 Subject: [PATCH] address review comments --- api/resolvers/item.js | 12 ++++++++---- lib/time.js | 4 ---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/api/resolvers/item.js b/api/resolvers/item.js index eae34ca10..6df9f030d 100644 --- a/api/resolvers/item.js +++ b/api/resolvers/item.js @@ -20,7 +20,12 @@ import { notifyItemParents, notifyUserSubscribers, notifyZapped } from '../../li import { createHmac } from './wallet' import { settleHodlInvoice } from 'ln-service' import { initDateRule } from '../../lib/timedate-scraper' +<<<<<<< HEAD import { moreThanOneYearAgo } from '../../lib/time' +======= +import { datePivot } from '../../lib/time' +import { notifyItemParents, notifyUserSubscribers, notifyZapped } from '../../lib/push-notifications' +>>>>>>> 7be35e0 (address review comments) export async function commentFilterClause (me, models) { let clause = ` AND ("Item"."weightedVotes" - "Item"."weightedDownVotes" > -${ITEM_FILTER_THRESHOLD}` @@ -546,12 +551,11 @@ export default { const doc = domino.createWindow(html).document initDateRule() const metadata = getMetadata(doc, url, { title: metadataRuleSets.title, publicationDate: metadataRuleSets.publicationDate }) - const dateHint = ` (${metadata.publicationDate.getFullYear()})` + const dateHint = ` (${metadata.publicationDate?.getFullYear()})` + const moreThanOneYearAgo = metadata.publicationDate && metadata.publicationDate < datePivot(new Date(), { years: -1 }) res.title = metadata?.title - if (moreThanOneYearAgo(metadata.publicationDate)) { - res.title += dateHint - } + if (moreThanOneYearAgo) res.title += dateHint } catch { } try { diff --git a/lib/time.js b/lib/time.js index 46e2cac97..45f95985c 100644 --- a/lib/time.js +++ b/lib/time.js @@ -58,7 +58,3 @@ export function timeLeft (timeStamp) { } export const sleep = (ms) => new Promise((resolve, reject) => setTimeout(resolve, ms)) - -export function moreThanOneYearAgo (date) { - return date < datePivot(new Date(), { years: -1 }) -}