fix issues with new linting
This commit is contained in:
parent
041b711c21
commit
ab2046ab0b
@ -110,7 +110,7 @@ export default function Comment ({
|
|||||||
const [pendingSats, setPendingSats] = useState(0)
|
const [pendingSats, setPendingSats] = useState(0)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setCollapse(localStorage.getItem(`commentCollapse:${item.id}`) || collapse)
|
setCollapse(window.localStorage.getItem(`commentCollapse:${item.id}`) || collapse)
|
||||||
if (Number(router.query.commentId) === Number(item.id)) {
|
if (Number(router.query.commentId) === Number(item.id)) {
|
||||||
// HACK wait for other comments to collapse if they're collapsed
|
// HACK wait for other comments to collapse if they're collapsed
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@ -134,7 +134,7 @@ export default function Comment ({
|
|||||||
>
|
>
|
||||||
<div className={`${itemStyles.item} ${styles.item}`}>
|
<div className={`${itemStyles.item} ${styles.item}`}>
|
||||||
{item.meDontLike
|
{item.meDontLike
|
||||||
? <Flag width={24} height={24} className={`${styles.dontLike}`} />
|
? <Flag width={24} height={24} className={styles.dontLike} />
|
||||||
: <UpVote item={item} className={styles.upvote} pendingSats={pendingSats} setPendingSats={setPendingSats} />}
|
: <UpVote item={item} className={styles.upvote} pendingSats={pendingSats} setPendingSats={setPendingSats} />}
|
||||||
<div className={`${itemStyles.hunk} ${styles.hunk}`}>
|
<div className={`${itemStyles.hunk} ${styles.hunk}`}>
|
||||||
<div className='d-flex align-items-center'>
|
<div className='d-flex align-items-center'>
|
||||||
@ -160,13 +160,13 @@ export default function Comment ({
|
|||||||
? <Eye
|
? <Eye
|
||||||
className={styles.collapser} height={10} width={10} onClick={() => {
|
className={styles.collapser} height={10} width={10} onClick={() => {
|
||||||
setCollapse('nope')
|
setCollapse('nope')
|
||||||
localStorage.setItem(`commentCollapse:${item.id}`, 'nope')
|
window.localStorage.setItem(`commentCollapse:${item.id}`, 'nope')
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
: <EyeClose
|
: <EyeClose
|
||||||
className={styles.collapser} height={10} width={10} onClick={() => {
|
className={styles.collapser} height={10} width={10} onClick={() => {
|
||||||
setCollapse('yep')
|
setCollapse('yep')
|
||||||
localStorage.setItem(`commentCollapse:${item.id}`, 'yep')
|
window.localStorage.setItem(`commentCollapse:${item.id}`, 'yep')
|
||||||
}}
|
}}
|
||||||
/>)}
|
/>)}
|
||||||
{topLevel && (
|
{topLevel && (
|
||||||
@ -197,7 +197,7 @@ export default function Comment ({
|
|||||||
bottomedOut
|
bottomedOut
|
||||||
? <DepthLimit item={item} />
|
? <DepthLimit item={item} />
|
||||||
: (
|
: (
|
||||||
<div className={`${styles.children}`}>
|
<div className={styles.children}>
|
||||||
{!noReply &&
|
{!noReply &&
|
||||||
<Reply depth={depth + 1} item={item} replyOpen={replyOpen}>
|
<Reply depth={depth + 1} item={item} replyOpen={replyOpen}>
|
||||||
{root.bounty && !bountyPaid && <PayBounty item={item} />}
|
{root.bounty && !bountyPaid && <PayBounty item={item} />}
|
||||||
@ -227,7 +227,7 @@ function DepthLimit ({ item }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={`${styles.children}`}>
|
<div className={styles.children}>
|
||||||
<ReplyOnAnotherPage parentId={item.id} />
|
<ReplyOnAnotherPage parentId={item.id} />
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { Component } from 'react'
|
import { Component } from 'react'
|
||||||
import { StaticLayout } from './layout'
|
import { StaticLayout } from './layout'
|
||||||
import styles from '../styles/404.module.css'
|
import styles from '../styles/404.module.css'
|
||||||
|
import Image from 'react-bootstrap/Image'
|
||||||
|
|
||||||
class ErrorBoundary extends Component {
|
class ErrorBoundary extends Component {
|
||||||
constructor (props) {
|
constructor (props) {
|
||||||
|
@ -128,15 +128,15 @@ export default function Footer ({ links = true }) {
|
|||||||
const [lightning, setLightning] = useState(undefined)
|
const [lightning, setLightning] = useState(undefined)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setLightning(localStorage.getItem('lnAnimate') || 'yes')
|
setLightning(window.localStorage.getItem('lnAnimate') || 'yes')
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
const toggleLightning = () => {
|
const toggleLightning = () => {
|
||||||
if (lightning === 'yes') {
|
if (lightning === 'yes') {
|
||||||
localStorage.setItem('lnAnimate', 'no')
|
window.localStorage.setItem('lnAnimate', 'no')
|
||||||
setLightning('no')
|
setLightning('no')
|
||||||
} else {
|
} else {
|
||||||
localStorage.setItem('lnAnimate', 'yes')
|
window.localStorage.setItem('lnAnimate', 'yes')
|
||||||
setLightning('yes')
|
setLightning('yes')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -231,10 +231,10 @@ function InputInner ({
|
|||||||
if (overrideValue) {
|
if (overrideValue) {
|
||||||
helpers.setValue(overrideValue)
|
helpers.setValue(overrideValue)
|
||||||
if (storageKey) {
|
if (storageKey) {
|
||||||
localStorage.setItem(storageKey, overrideValue)
|
window.localStorage.setItem(storageKey, overrideValue)
|
||||||
}
|
}
|
||||||
} else if (storageKey) {
|
} else if (storageKey) {
|
||||||
const draft = localStorage.getItem(storageKey)
|
const draft = window.localStorage.getItem(storageKey)
|
||||||
if (draft) {
|
if (draft) {
|
||||||
// for some reason we have to turn off validation to get formik to
|
// for some reason we have to turn off validation to get formik to
|
||||||
// not assume this is invalid
|
// not assume this is invalid
|
||||||
@ -264,7 +264,7 @@ function InputInner ({
|
|||||||
field.onChange(e)
|
field.onChange(e)
|
||||||
|
|
||||||
if (storageKey) {
|
if (storageKey) {
|
||||||
localStorage.setItem(storageKey, e.target.value)
|
window.localStorage.setItem(storageKey, e.target.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (onChange) {
|
if (onChange) {
|
||||||
@ -280,7 +280,7 @@ function InputInner ({
|
|||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
helpers.setValue('')
|
helpers.setValue('')
|
||||||
if (storageKey) {
|
if (storageKey) {
|
||||||
localStorage.removeItem(storageKey)
|
window.localStorage.removeItem(storageKey)
|
||||||
}
|
}
|
||||||
if (onChange) {
|
if (onChange) {
|
||||||
onChange(formik, { target: { value: '' } })
|
onChange(formik, { target: { value: '' } })
|
||||||
@ -460,10 +460,10 @@ export function Form ({
|
|||||||
onSubmit && onSubmit(values, ...args).then(() => {
|
onSubmit && onSubmit(values, ...args).then(() => {
|
||||||
if (!storageKeyPrefix) return
|
if (!storageKeyPrefix) return
|
||||||
Object.keys(values).forEach(v => {
|
Object.keys(values).forEach(v => {
|
||||||
localStorage.removeItem(storageKeyPrefix + '-' + v)
|
window.localStorage.removeItem(storageKeyPrefix + '-' + v)
|
||||||
if (Array.isArray(values[v])) {
|
if (Array.isArray(values[v])) {
|
||||||
values[v].forEach(
|
values[v].forEach(
|
||||||
(_, i) => localStorage.removeItem(`${storageKeyPrefix}-${v}[${i}]`))
|
(_, i) => window.localStorage.removeItem(`${storageKeyPrefix}-${v}[${i}]`))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -134,10 +134,10 @@ function LurkerCorner ({ path }) {
|
|||||||
const strike = useLightning()
|
const strike = useLightning()
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!localStorage.getItem('striked')) {
|
if (!window.localStorage.getItem('striked')) {
|
||||||
const to = setTimeout(() => {
|
const to = setTimeout(() => {
|
||||||
strike()
|
strike()
|
||||||
localStorage.setItem('striked', 'yep')
|
window.localStorage.setItem('striked', 'yep')
|
||||||
}, randInRange(3000, 10000))
|
}, randInRange(3000, 10000))
|
||||||
return () => clearTimeout(to)
|
return () => clearTimeout(to)
|
||||||
}
|
}
|
||||||
@ -263,7 +263,7 @@ export default function Header ({ sub }) {
|
|||||||
</Navbar>
|
</Navbar>
|
||||||
<Navbar className='pt-0 pb-2 d-lg-none'>
|
<Navbar className='pt-0 pb-2 d-lg-none'>
|
||||||
<Nav
|
<Nav
|
||||||
className={`${styles.navbarNav}`}
|
className={styles.navbarNav}
|
||||||
activeKey={topNavKey}
|
activeKey={topNavKey}
|
||||||
>
|
>
|
||||||
<NavItems className='me-1' prefix={prefix} sub={sub} />
|
<NavItems className='me-1' prefix={prefix} sub={sub} />
|
||||||
@ -289,7 +289,7 @@ export function HeaderStatic () {
|
|||||||
<div className='d-flex align-items-center'>
|
<div className='d-flex align-items-center'>
|
||||||
<Back />
|
<Back />
|
||||||
<Link href='/' passHref legacyBehavior>
|
<Link href='/' passHref legacyBehavior>
|
||||||
<Navbar.Brand className={`${styles.brand}`}>
|
<Navbar.Brand className={styles.brand}>
|
||||||
SN
|
SN
|
||||||
</Navbar.Brand>
|
</Navbar.Brand>
|
||||||
</Link>
|
</Link>
|
||||||
|
@ -25,7 +25,7 @@ const Tips = ({ setOValue }) => {
|
|||||||
</Button>)
|
</Button>)
|
||||||
}
|
}
|
||||||
|
|
||||||
const getCustomTips = () => JSON.parse(localStorage.getItem('custom-tips')) || []
|
const getCustomTips = () => JSON.parse(window.localStorage.getItem('custom-tips')) || []
|
||||||
|
|
||||||
const addCustomTip = (amount) => {
|
const addCustomTip = (amount) => {
|
||||||
if (defaultTips.includes(amount)) return
|
if (defaultTips.includes(amount)) return
|
||||||
@ -33,7 +33,7 @@ const addCustomTip = (amount) => {
|
|||||||
if (customTips.length > 3) {
|
if (customTips.length > 3) {
|
||||||
customTips = customTips.slice(0, 3)
|
customTips = customTips.slice(0, 3)
|
||||||
}
|
}
|
||||||
localStorage.setItem('custom-tips', JSON.stringify(customTips))
|
window.localStorage.setItem('custom-tips', JSON.stringify(customTips))
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function ItemAct ({ onClose, itemId, act, strike }) {
|
export default function ItemAct ({ onClose, itemId, act, strike }) {
|
||||||
|
@ -22,7 +22,7 @@ export default function ItemJob ({ item, toc, rank, children }) {
|
|||||||
{rank}
|
{rank}
|
||||||
</div>)
|
</div>)
|
||||||
: <div />}
|
: <div />}
|
||||||
<div className={`${styles.item}`}>
|
<div className={styles.item}>
|
||||||
<Link href={`/items/${item.id}`}>
|
<Link href={`/items/${item.id}`}>
|
||||||
<Image
|
<Image
|
||||||
src={item.uploadId ? `https://${process.env.NEXT_PUBLIC_AWS_UPLOAD_BUCKET}.s3.amazonaws.com/${item.uploadId}` : '/jobs-default.png'} width='42' height='42' className={styles.companyImage}
|
src={item.uploadId ? `https://${process.env.NEXT_PUBLIC_AWS_UPLOAD_BUCKET}.s3.amazonaws.com/${item.uploadId}` : '/jobs-default.png'} width='42' height='42' className={styles.companyImage}
|
||||||
@ -37,7 +37,7 @@ export default function ItemJob ({ item, toc, rank, children }) {
|
|||||||
<>{item.title}</>)}
|
<>{item.title}</>)}
|
||||||
</Link>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
<div className={`${styles.other}`}>
|
<div className={styles.other}>
|
||||||
{item.company &&
|
{item.company &&
|
||||||
<>
|
<>
|
||||||
{item.company}
|
{item.company}
|
||||||
@ -78,7 +78,7 @@ export default function ItemJob ({ item, toc, rank, children }) {
|
|||||||
</>}
|
</>}
|
||||||
</div>
|
</div>
|
||||||
{children && (
|
{children && (
|
||||||
<div className={`${styles.children}`} style={{ marginLeft: 'calc(42px + .8rem)' }}>
|
<div className={styles.children} style={{ marginLeft: 'calc(42px + .8rem)' }}>
|
||||||
<div className='mb-3 d-flex'>
|
<div className='mb-3 d-flex'>
|
||||||
<Button
|
<Button
|
||||||
target='_blank' href={isEmail ? `mailto:${item.url}?subject=${encodeURIComponent(item.title)} via Stacker News` : item.url}
|
target='_blank' href={isEmail ? `mailto:${item.url}?subject=${encodeURIComponent(item.title)} via Stacker News` : item.url}
|
||||||
|
@ -36,7 +36,7 @@ export default function Item ({ item, rank, belowTitle, right, full, children, s
|
|||||||
<div className={`${styles.item} ${siblingComments ? 'pt-2' : ''}`}>
|
<div className={`${styles.item} ${siblingComments ? 'pt-2' : ''}`}>
|
||||||
{item.position
|
{item.position
|
||||||
? <Pin width={24} height={24} className={styles.pin} />
|
? <Pin width={24} height={24} className={styles.pin} />
|
||||||
: item.meDontLike ? <Flag width={24} height={24} className={`${styles.dontLike}`} /> : <UpVote item={item} className={styles.upvote} pendingSats={pendingSats} setPendingSats={setPendingSats} />}
|
: item.meDontLike ? <Flag width={24} height={24} className={styles.dontLike} /> : <UpVote item={item} className={styles.upvote} pendingSats={pendingSats} setPendingSats={setPendingSats} />}
|
||||||
<div className={styles.hunk}>
|
<div className={styles.hunk}>
|
||||||
<div className={`${styles.main} flex-wrap`}>
|
<div className={`${styles.main} flex-wrap`}>
|
||||||
<Link href={`/items/${item.id}`} ref={titleRef} className={`${styles.title} text-reset me-2`}>
|
<Link href={`/items/${item.id}`} ref={titleRef} className={`${styles.title} text-reset me-2`}>
|
||||||
@ -54,7 +54,7 @@ export default function Item ({ item, rank, belowTitle, right, full, children, s
|
|||||||
<>
|
<>
|
||||||
{/* eslint-disable-next-line */}
|
{/* eslint-disable-next-line */}
|
||||||
<a
|
<a
|
||||||
className={`${styles.link}`} target='_blank' href={item.url}
|
className={styles.link} target='_blank' href={item.url}
|
||||||
rel={item.sats + item.boost >= NOFOLLOW_LIMIT ? null : 'nofollow'}
|
rel={item.sats + item.boost >= NOFOLLOW_LIMIT ? null : 'nofollow'}
|
||||||
>
|
>
|
||||||
{item.url.replace(/(^https?:|^)\/\//, '')}
|
{item.url.replace(/(^https?:|^)\/\//, '')}
|
||||||
|
@ -175,7 +175,7 @@ function PromoteJob ({ item, sub, storageKeyPrefix }) {
|
|||||||
const position = data?.auctionPosition
|
const position = data?.auctionPosition
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const initialMaxBid = Number(item?.maxBid || localStorage.getItem(storageKeyPrefix + '-maxBid')) || 0
|
const initialMaxBid = Number(item?.maxBid || window.localStorage.getItem(storageKeyPrefix + '-maxBid')) || 0
|
||||||
getAuctionPosition({ variables: { id: item?.id, bid: initialMaxBid } })
|
getAuctionPosition({ variables: { id: item?.id, bid: initialMaxBid } })
|
||||||
setMonthly(satsMin2Mo(initialMaxBid))
|
setMonthly(satsMin2Mo(initialMaxBid))
|
||||||
}, [])
|
}, [])
|
||||||
|
@ -9,7 +9,7 @@ export class LightningProvider extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
strike = () => {
|
strike = () => {
|
||||||
const should = localStorage.getItem('lnAnimate') || 'yes'
|
const should = window.localStorage.getItem('lnAnimate') || 'yes'
|
||||||
if (should === 'yes') {
|
if (should === 'yes') {
|
||||||
this.setState(state => {
|
this.setState(state => {
|
||||||
return {
|
return {
|
||||||
|
@ -268,14 +268,14 @@ function NotificationAlert () {
|
|||||||
const isSupported = sw.support.serviceWorker && sw.support.pushManager && sw.support.notification
|
const isSupported = sw.support.serviceWorker && sw.support.pushManager && sw.support.notification
|
||||||
if (isSupported) {
|
if (isSupported) {
|
||||||
const isDefaultPermission = sw.permission.notification === 'default'
|
const isDefaultPermission = sw.permission.notification === 'default'
|
||||||
setShowAlert(isDefaultPermission && !localStorage.getItem('hideNotifyPrompt'))
|
setShowAlert(isDefaultPermission && !window.localStorage.getItem('hideNotifyPrompt'))
|
||||||
sw.registration?.pushManager.getSubscription().then(subscription => setHasSubscription(!!subscription))
|
sw.registration?.pushManager.getSubscription().then(subscription => setHasSubscription(!!subscription))
|
||||||
setSupported(true)
|
setSupported(true)
|
||||||
}
|
}
|
||||||
}, [sw])
|
}, [sw])
|
||||||
|
|
||||||
const close = () => {
|
const close = () => {
|
||||||
localStorage.setItem('hideNotifyPrompt', 'yep')
|
window.localStorage.setItem('hideNotifyPrompt', 'yep')
|
||||||
setShowAlert(false)
|
setShowAlert(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -299,7 +299,7 @@ function NotificationAlert () {
|
|||||||
}}
|
}}
|
||||||
>Yes
|
>Yes
|
||||||
</button>
|
</button>
|
||||||
<button className={`${styles.alertBtn}`} onClick={close}>No</button>
|
<button className={styles.alertBtn} onClick={close}>No</button>
|
||||||
</Alert>
|
</Alert>
|
||||||
)
|
)
|
||||||
: (
|
: (
|
||||||
|
@ -38,7 +38,7 @@ export function PriceProvider ({ price, children }) {
|
|||||||
export default function Price ({ className }) {
|
export default function Price ({ className }) {
|
||||||
const [asSats, setAsSats] = useState(undefined)
|
const [asSats, setAsSats] = useState(undefined)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setAsSats(localStorage.getItem('asSats'))
|
setAsSats(window.localStorage.getItem('asSats'))
|
||||||
}, [])
|
}, [])
|
||||||
const { price, fiatSymbol } = usePrice()
|
const { price, fiatSymbol } = usePrice()
|
||||||
|
|
||||||
@ -46,13 +46,13 @@ export default function Price ({ className }) {
|
|||||||
|
|
||||||
const handleClick = () => {
|
const handleClick = () => {
|
||||||
if (asSats === 'yep') {
|
if (asSats === 'yep') {
|
||||||
localStorage.setItem('asSats', '1btc')
|
window.localStorage.setItem('asSats', '1btc')
|
||||||
setAsSats('1btc')
|
setAsSats('1btc')
|
||||||
} else if (asSats === '1btc') {
|
} else if (asSats === '1btc') {
|
||||||
localStorage.removeItem('asSats')
|
window.localStorage.removeItem('asSats')
|
||||||
setAsSats(undefined)
|
setAsSats(undefined)
|
||||||
} else {
|
} else {
|
||||||
localStorage.setItem('asSats', 'yep')
|
window.localStorage.setItem('asSats', 'yep')
|
||||||
setAsSats('yep')
|
setAsSats('yep')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ export default function Reply ({ item, onSuccess, replyOpen, children, placehold
|
|||||||
const parentId = item.id
|
const parentId = item.id
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setReply(replyOpen || !!localStorage.getItem('reply-' + parentId + '-' + 'text'))
|
setReply(replyOpen || !!window.localStorage.getItem('reply-' + parentId + '-' + 'text'))
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
const [createComment] = useMutation(
|
const [createComment] = useMutation(
|
||||||
|
@ -101,7 +101,7 @@ export default function Search ({ sub }) {
|
|||||||
|
|
||||||
</>}
|
</>}
|
||||||
</div>}
|
</div>}
|
||||||
<div className={`${styles.active}`}>
|
<div className={styles.active}>
|
||||||
<Input
|
<Input
|
||||||
name='q'
|
name='q'
|
||||||
required
|
required
|
||||||
|
@ -13,7 +13,7 @@ export function SeoSearch ({ sub }) {
|
|||||||
title={title}
|
title={title}
|
||||||
description={desc}
|
description={desc}
|
||||||
openGraph={{
|
openGraph={{
|
||||||
title: title,
|
title,
|
||||||
description: desc,
|
description: desc,
|
||||||
images: [
|
images: [
|
||||||
{
|
{
|
||||||
|
@ -43,7 +43,7 @@ export const ServiceWorkerProvider = ({ children }) => {
|
|||||||
const requestNotificationPermission = useCallback(() => {
|
const requestNotificationPermission = useCallback(() => {
|
||||||
// https://web.dev/push-notifications-subscribing-a-user/#requesting-permission
|
// https://web.dev/push-notifications-subscribing-a-user/#requesting-permission
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
const permission = Notification.requestPermission(function (result) {
|
const permission = window.Notification.requestPermission(function (result) {
|
||||||
resolve(result)
|
resolve(result)
|
||||||
})
|
})
|
||||||
if (permission) {
|
if (permission) {
|
||||||
@ -88,7 +88,7 @@ export const ServiceWorkerProvider = ({ children }) => {
|
|||||||
notification: 'Notification' in window,
|
notification: 'Notification' in window,
|
||||||
pushManager: 'PushManager' in window
|
pushManager: 'PushManager' in window
|
||||||
})
|
})
|
||||||
setPermission({ notification: 'Notification' in window ? Notification.permission : 'denied' })
|
setPermission({ notification: 'Notification' in window ? window.Notification.permission : 'denied' })
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -11,7 +11,7 @@ export default function Snl ({ ignorePreference }) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const dismissed = localStorage.getItem('snl')
|
const dismissed = window.localStorage.getItem('snl')
|
||||||
if (!ignorePreference && dismissed && dismissed > new Date(dismissed) < dayPivot(new Date(), -6)) {
|
if (!ignorePreference && dismissed && dismissed > new Date(dismissed) < dayPivot(new Date(), -6)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -27,7 +27,7 @@ export default function Snl ({ ignorePreference }) {
|
|||||||
variant='info' className='fw-bold mb-3 d-flex py-2 flex-shrink align-items-center'
|
variant='info' className='fw-bold mb-3 d-flex py-2 flex-shrink align-items-center'
|
||||||
onClose={() => {
|
onClose={() => {
|
||||||
setShow(undefined)
|
setShow(undefined)
|
||||||
localStorage.setItem('snl', new Date())
|
window.localStorage.setItem('snl', new Date())
|
||||||
}}
|
}}
|
||||||
dismissible
|
dismissible
|
||||||
>
|
>
|
||||||
|
@ -88,7 +88,7 @@ export default memo(function Text ({ topLevel, noFragments, nofollow, onlyImgPro
|
|||||||
if (imgRegexp.test(url)) {
|
if (imgRegexp.test(url)) {
|
||||||
setUrlCache((prev) => ({ ...prev, [url]: CACHE_STATES.IS_LOADED }))
|
setUrlCache((prev) => ({ ...prev, [url]: CACHE_STATES.IS_LOADED }))
|
||||||
} else if (!onlyImgProxy) {
|
} else if (!onlyImgProxy) {
|
||||||
const img = new Image()
|
const img = new window.Image()
|
||||||
imgCache.current[url] = img
|
imgCache.current[url] = img
|
||||||
|
|
||||||
setUrlCache((prev) => ({ ...prev, [url]: CACHE_STATES.IS_LOADING }))
|
setUrlCache((prev) => ({ ...prev, [url]: CACHE_STATES.IS_LOADING }))
|
||||||
|
@ -16,7 +16,7 @@ export default function Upload ({ as: Component, onSelect, onStarted, onError, o
|
|||||||
const upload = file => {
|
const upload = file => {
|
||||||
onStarted && onStarted()
|
onStarted && onStarted()
|
||||||
|
|
||||||
const img = new Image()
|
const img = new window.Image()
|
||||||
img.src = window.URL.createObjectURL(file)
|
img.src = window.URL.createObjectURL(file)
|
||||||
img.onload = async () => {
|
img.onload = async () => {
|
||||||
let data
|
let data
|
||||||
|
@ -3,21 +3,21 @@ const COMMENTS_NUM_PREFIX = 'commentsViewNum'
|
|||||||
|
|
||||||
export function commentsViewed (item) {
|
export function commentsViewed (item) {
|
||||||
if (!item.parentId && item.lastCommentAt) {
|
if (!item.parentId && item.lastCommentAt) {
|
||||||
localStorage.setItem(`${COMMENTS_VIEW_PREFIX}:${item.id}`, new Date(item.lastCommentAt).getTime())
|
window.localStorage.setItem(`${COMMENTS_VIEW_PREFIX}:${item.id}`, new Date(item.lastCommentAt).getTime())
|
||||||
localStorage.setItem(`${COMMENTS_NUM_PREFIX}:${item.id}`, item.ncomments)
|
window.localStorage.setItem(`${COMMENTS_NUM_PREFIX}:${item.id}`, item.ncomments)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function commentsViewedAfterComment (rootId, createdAt) {
|
export function commentsViewedAfterComment (rootId, createdAt) {
|
||||||
localStorage.setItem(`${COMMENTS_VIEW_PREFIX}:${rootId}`, new Date(createdAt).getTime())
|
window.localStorage.setItem(`${COMMENTS_VIEW_PREFIX}:${rootId}`, new Date(createdAt).getTime())
|
||||||
const existingRootComments = localStorage.getItem(`${COMMENTS_NUM_PREFIX}:${rootId}`) || 0
|
const existingRootComments = window.localStorage.getItem(`${COMMENTS_NUM_PREFIX}:${rootId}`) || 0
|
||||||
localStorage.setItem(`${COMMENTS_NUM_PREFIX}:${rootId}`, existingRootComments + 1)
|
window.localStorage.setItem(`${COMMENTS_NUM_PREFIX}:${rootId}`, existingRootComments + 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function newComments (item) {
|
export function newComments (item) {
|
||||||
if (!item.parentId) {
|
if (!item.parentId) {
|
||||||
const commentsViewedAt = localStorage.getItem(`${COMMENTS_VIEW_PREFIX}:${item.id}`)
|
const commentsViewedAt = window.localStorage.getItem(`${COMMENTS_VIEW_PREFIX}:${item.id}`)
|
||||||
const commentsViewNum = localStorage.getItem(`${COMMENTS_NUM_PREFIX}:${item.id}`)
|
const commentsViewNum = window.localStorage.getItem(`${COMMENTS_NUM_PREFIX}:${item.id}`)
|
||||||
|
|
||||||
if (commentsViewedAt && commentsViewNum) {
|
if (commentsViewedAt && commentsViewNum) {
|
||||||
return commentsViewedAt < new Date(item.lastCommentAt).getTime() || commentsViewNum < item.ncomments
|
return commentsViewedAt < new Date(item.lastCommentAt).getTime() || commentsViewNum < item.ncomments
|
||||||
|
@ -91,6 +91,9 @@
|
|||||||
},
|
},
|
||||||
"standard": {
|
"standard": {
|
||||||
"parser": "@babel/eslint-parser",
|
"parser": "@babel/eslint-parser",
|
||||||
|
"plugins": [
|
||||||
|
"@next/next"
|
||||||
|
],
|
||||||
"extends": [
|
"extends": [
|
||||||
"next"
|
"next"
|
||||||
]
|
]
|
||||||
|
@ -20,7 +20,7 @@ function writeQuery (client, apollo, data) {
|
|||||||
if (apollo && data) {
|
if (apollo && data) {
|
||||||
client.writeQuery({
|
client.writeQuery({
|
||||||
query: gql`${apollo.query}`,
|
query: gql`${apollo.query}`,
|
||||||
data: data,
|
data,
|
||||||
variables: apollo.variables,
|
variables: apollo.variables,
|
||||||
broadcast: !SSR,
|
broadcast: !SSR,
|
||||||
overwrite: SSR
|
overwrite: SSR
|
||||||
|
@ -11,7 +11,7 @@ export default async ({ query }, res) => {
|
|||||||
const sig = Buffer.from(query.sig, 'hex')
|
const sig = Buffer.from(query.sig, 'hex')
|
||||||
const k1 = Buffer.from(query.k1, 'hex')
|
const k1 = Buffer.from(query.k1, 'hex')
|
||||||
const key = Buffer.from(query.key, 'hex')
|
const key = Buffer.from(query.key, 'hex')
|
||||||
if (secp256k1.verify(signature, k1, key)) {
|
if (secp256k1.verify(sig, k1, key)) {
|
||||||
const auth = await models.lnAuth.findUnique({ where: { k1: query.k1 } })
|
const auth = await models.lnAuth.findUnique({ where: { k1: query.k1 } })
|
||||||
if (!auth || auth.pubkey || auth.createdAt < Date.now() - HOUR) {
|
if (!auth || auth.pubkey || auth.createdAt < Date.now() - HOUR) {
|
||||||
return res.status(400).json({ status: 'ERROR', reason: 'token expired' })
|
return res.status(400).json({ status: 'ERROR', reason: 'token expired' })
|
||||||
|
@ -3,7 +3,7 @@ import lnd from '../../../../api/lnd'
|
|||||||
import { createInvoice } from 'ln-service'
|
import { createInvoice } from 'ln-service'
|
||||||
import { lnurlPayDescriptionHashForUser } from '../../../../lib/lnurl'
|
import { lnurlPayDescriptionHashForUser } from '../../../../lib/lnurl'
|
||||||
import serialize from '../../../../api/resolvers/serial'
|
import serialize from '../../../../api/resolvers/serial'
|
||||||
import { schnorr } from '@noble/curves/secp256k1';
|
import { schnorr } from '@noble/curves/secp256k1'
|
||||||
import { createHash } from 'crypto'
|
import { createHash } from 'crypto'
|
||||||
|
|
||||||
export default async ({ query: { username, amount, nostr } }, res) => {
|
export default async ({ query: { username, amount, nostr } }, res) => {
|
||||||
@ -38,7 +38,7 @@ export default async ({ query: { username, amount, nostr } }, res) => {
|
|||||||
// generate invoice
|
// generate invoice
|
||||||
const expiresAt = new Date(new Date().setMinutes(new Date().getMinutes() + 1))
|
const expiresAt = new Date(new Date().setMinutes(new Date().getMinutes() + 1))
|
||||||
const invoice = await createInvoice({
|
const invoice = await createInvoice({
|
||||||
description: description,
|
description,
|
||||||
description_hash: descriptionHash,
|
description_hash: descriptionHash,
|
||||||
lnd,
|
lnd,
|
||||||
mtokens: amount,
|
mtokens: amount,
|
||||||
|
@ -2,11 +2,6 @@ import { gql } from 'graphql-tag'
|
|||||||
import { useEffect, useState } from 'react'
|
import { useEffect, useState } from 'react'
|
||||||
import Button from 'react-bootstrap/Button'
|
import Button from 'react-bootstrap/Button'
|
||||||
import InputGroup from 'react-bootstrap/InputGroup'
|
import InputGroup from 'react-bootstrap/InputGroup'
|
||||||
import { PieChart } from 'recharts/lib/chart/PieChart'
|
|
||||||
import { Cell } from 'recharts/lib/component/Cell'
|
|
||||||
import { Pie } from 'recharts/lib/polar/Pie'
|
|
||||||
import { Tooltip } from 'recharts/lib/component/Tooltip'
|
|
||||||
import { ResponsiveContainer } from 'recharts/lib/component/ResponsiveContainer'
|
|
||||||
import { getGetServerSideProps } from '../api/ssrApollo'
|
import { getGetServerSideProps } from '../api/ssrApollo'
|
||||||
import { Form, Input, SubmitButton } from '../components/form'
|
import { Form, Input, SubmitButton } from '../components/form'
|
||||||
import { CenterLayout } from '../components/layout'
|
import { CenterLayout } from '../components/layout'
|
||||||
@ -94,14 +89,6 @@ export default function Rewards ({ ssrData }) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const COLORS = [
|
|
||||||
'var(--bs-secondary)',
|
|
||||||
'var(--bs-info)',
|
|
||||||
'var(--bs-success)',
|
|
||||||
'var(--bs-boost)',
|
|
||||||
'var(--bs-grey)'
|
|
||||||
]
|
|
||||||
|
|
||||||
export function DonateButton () {
|
export function DonateButton () {
|
||||||
const showModal = useShowModal()
|
const showModal = useShowModal()
|
||||||
const [donateToRewards] = useMutation(
|
const [donateToRewards] = useMutation(
|
||||||
|
@ -5,14 +5,14 @@ import Col from 'react-bootstrap/Col'
|
|||||||
import Row from 'react-bootstrap/Row'
|
import Row from 'react-bootstrap/Row'
|
||||||
import { UsageHeader } from '../../components/usage-header'
|
import { UsageHeader } from '../../components/usage-header'
|
||||||
import { useRouter } from 'next/router'
|
import { useRouter } from 'next/router'
|
||||||
import dynamic from "next/dynamic"
|
import dynamic from 'next/dynamic'
|
||||||
|
|
||||||
const WhenAreaChart = dynamic(() => import('../../components/charts').then(mod => mod.WhenAreaChart), {
|
const WhenAreaChart = dynamic(() => import('../../components/charts').then(mod => mod.WhenAreaChart), {
|
||||||
loading: () => <div>Loading...</div>
|
loading: () => <div>Loading...</div>
|
||||||
});
|
})
|
||||||
const WhenLineChart = dynamic(() => import('../../components/charts').then(mod => mod.WhenLineChart), {
|
const WhenLineChart = dynamic(() => import('../../components/charts').then(mod => mod.WhenLineChart), {
|
||||||
loading: () => <div>Loading...</div>
|
loading: () => <div>Loading...</div>
|
||||||
});
|
})
|
||||||
|
|
||||||
export const getServerSideProps = getGetServerSideProps(
|
export const getServerSideProps = getGetServerSideProps(
|
||||||
gql`
|
gql`
|
||||||
|
@ -86,7 +86,7 @@ export function FundForm () {
|
|||||||
}`)
|
}`)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setShowAlert(!localStorage.getItem('hideLnAddrAlert'))
|
setShowAlert(!window.localStorage.getItem('hideLnAddrAlert'))
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
if (called && !error) {
|
if (called && !error) {
|
||||||
@ -99,7 +99,7 @@ export function FundForm () {
|
|||||||
{me && showAlert &&
|
{me && showAlert &&
|
||||||
<Alert
|
<Alert
|
||||||
variant='success' dismissible onClose={() => {
|
variant='success' dismissible onClose={() => {
|
||||||
localStorage.setItem('hideLnAddrAlert', 'yep')
|
window.localStorage.setItem('hideLnAddrAlert', 'yep')
|
||||||
setShowAlert(false)
|
setShowAlert(false)
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
@ -13,7 +13,7 @@ export default function Sub ({ ssrData }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Layout sub={variables.sub}>
|
<Layout sub={variables.sub}>
|
||||||
<Items ssrData={ssrData} rank variables={variables} />
|
<Items ssrData={ssrData} variables={variables} />
|
||||||
</Layout>
|
</Layout>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ export default function Index ({ ssrData }) {
|
|||||||
<Items
|
<Items
|
||||||
ssrData={ssrData}
|
ssrData={ssrData}
|
||||||
query={SUB_ITEMS}
|
query={SUB_ITEMS}
|
||||||
variables={variables} rank
|
variables={variables}
|
||||||
/>
|
/>
|
||||||
</Layout>
|
</Layout>
|
||||||
)
|
)
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
import getGetRssServerSideProps from '../../lib/rss'
|
import getGetRssServerSideProps from '../../lib/rss'
|
||||||
import { SUB_ITEMS } from '../../fragments/subs'
|
import { SUB_ITEMS } from '../../fragments/subs'
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ export default function Index ({ ssrData }) {
|
|||||||
<Items
|
<Items
|
||||||
ssrData={ssrData}
|
ssrData={ssrData}
|
||||||
query={SUB_ITEMS}
|
query={SUB_ITEMS}
|
||||||
variables={variables} rank
|
variables={variables}
|
||||||
noMoreText='NO MORE'
|
noMoreText='NO MORE'
|
||||||
/>
|
/>
|
||||||
</Layout>
|
</Layout>
|
||||||
|
@ -67,7 +67,7 @@ export const getTheme = () => {
|
|||||||
const supportsColorSchemeQuery = mql.media === PREFER_DARK_QUERY
|
const supportsColorSchemeQuery = mql.media === PREFER_DARK_QUERY
|
||||||
let localStorageTheme = null
|
let localStorageTheme = null
|
||||||
try {
|
try {
|
||||||
localStorageTheme = localStorage.getItem(STORAGE_KEY)
|
localStorageTheme = window.localStorage.getItem(STORAGE_KEY)
|
||||||
} catch (err) {}
|
} catch (err) {}
|
||||||
const localStorageExists = localStorageTheme !== null
|
const localStorageExists = localStorageTheme !== null
|
||||||
if (localStorageExists) {
|
if (localStorageExists) {
|
||||||
@ -82,7 +82,7 @@ export const getTheme = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const setTheme = (dark) => {
|
export const setTheme = (dark) => {
|
||||||
localStorage.setItem(STORAGE_KEY, JSON.stringify(dark))
|
window.localStorage.setItem(STORAGE_KEY, JSON.stringify(dark))
|
||||||
handleThemeChange(dark)
|
handleThemeChange(dark)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
/* global self */
|
||||||
import { precacheAndRoute } from 'workbox-precaching'
|
import { precacheAndRoute } from 'workbox-precaching'
|
||||||
import { offlineFallback } from 'workbox-recipes'
|
import { offlineFallback } from 'workbox-recipes'
|
||||||
import { setDefaultHandler } from 'workbox-routing'
|
import { setDefaultHandler } from 'workbox-routing'
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
// this is intended to be run everyday after midnight CT
|
// this is intended to be run everyday after midnight CT
|
||||||
function views ({ models }) {
|
function views ({ models }) {
|
||||||
return async function () {
|
return async function () {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user