parent
8620a35d33
commit
e7fb9e4749
3 changed files with 12 additions and 5 deletions
|
@ -6,7 +6,7 @@ import { makeStyles } from '@material-ui/core/styles'
|
|||
|
||||
import useSettings from './hooks/useSettings'
|
||||
import useRSSFeeds from './hooks/useRSSFeeds'
|
||||
import sortFeedItemsByDate from './utils/sortFeedItemsByDate'
|
||||
import sortFeedItemsByDate from './utils'
|
||||
|
||||
interface CardProps {
|
||||
title: string
|
||||
|
|
|
@ -2,6 +2,7 @@ import { parseFeed } from 'htmlparser2'
|
|||
import { useQueries } from 'react-query'
|
||||
|
||||
import { Feed } from '../types'
|
||||
import { isDev } from '../utils'
|
||||
|
||||
import useLocalStorage from './useLocalStorage'
|
||||
|
||||
|
@ -58,8 +59,10 @@ async function fetchFeed(
|
|||
|
||||
return mergedFeeds
|
||||
} catch (e) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(e)
|
||||
if (isDev()) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(e)
|
||||
}
|
||||
}
|
||||
|
||||
return persistedData
|
||||
|
@ -88,7 +91,7 @@ export default function useRSSFeeds(urls: string[]): { feeds: Feed[] } {
|
|||
)
|
||||
|
||||
const fetchedFeeds = queries.reduce((fetchedFeeds: Feed[], current) => {
|
||||
if (current.isSuccess) fetchedFeeds.push(current.data)
|
||||
if (current.isSuccess && current.data) fetchedFeeds.push(current.data)
|
||||
|
||||
return fetchedFeeds
|
||||
}, [])
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import type { Feed, Item } from '../types'
|
||||
import type { Feed, Item } from './types'
|
||||
|
||||
export default function sortFeedItemsByDate(feeds: Feed[]): Item[] {
|
||||
const flattened = feeds.reduce((flattenedFeeds, feed) => {
|
||||
|
@ -14,3 +14,7 @@ export default function sortFeedItemsByDate(feeds: Feed[]): Item[] {
|
|||
first.published > second.published ? -1 : 1,
|
||||
)
|
||||
}
|
||||
|
||||
export function isDev(): boolean {
|
||||
return process.env.NODE_ENV === 'development'
|
||||
}
|
Loading…
Reference in a new issue