Compare commits
6 Commits
033270b6ae
...
050122c665
Author | SHA1 | Date | |
---|---|---|---|
|
050122c665 | ||
|
6047c37e4e | ||
|
2e346b488d | ||
|
4e14e2b5d3 | ||
|
30718b9e1b | ||
|
738333efa3 |
@ -27,18 +27,11 @@ function commentsOrderByClause (me, models, sort) {
|
||||
return 'ORDER BY "Item".created_at DESC, "Item".id DESC'
|
||||
}
|
||||
|
||||
if (me) {
|
||||
if (sort === 'top') {
|
||||
return `ORDER BY COALESCE(
|
||||
personal_top_score,
|
||||
${orderByNumerator(models, 0)}) DESC NULLS LAST,
|
||||
"Item".msats DESC, ("Item".freebie IS FALSE) DESC, "Item".id DESC`
|
||||
} else {
|
||||
if (me && sort === 'hot') {
|
||||
return `ORDER BY COALESCE(
|
||||
personal_hot_score,
|
||||
${orderByNumerator(models, 0)}/POWER(GREATEST(3, EXTRACT(EPOCH FROM (now_utc() - "Item".created_at))/3600), 1.3)) DESC NULLS LAST,
|
||||
"Item".msats DESC, ("Item".freebie IS FALSE) DESC, "Item".id DESC`
|
||||
}
|
||||
} else {
|
||||
if (sort === 'top') {
|
||||
return `ORDER BY ${orderByNumerator(models, 0)} DESC NULLS LAST, "Item".msats DESC, ("Item".freebie IS FALSE) DESC, "Item".id DESC`
|
||||
@ -373,28 +366,6 @@ export default {
|
||||
}, decodedCursor.time, decodedCursor.offset, limit, ...subArr)
|
||||
break
|
||||
case 'top':
|
||||
if (me && (!by || by === 'zaprank') && (when === 'day' || when === 'week')) {
|
||||
// personalized zaprank only goes back 7 days
|
||||
items = await itemQueryWithMeta({
|
||||
me,
|
||||
models,
|
||||
query: `
|
||||
${SELECT}, GREATEST(g.tf_top_score, l.tf_top_score) AS rank
|
||||
${relationClause(type)}
|
||||
${joinZapRankPersonalView(me, models)}
|
||||
${whereClause(
|
||||
'"Item"."deletedAt" IS NULL',
|
||||
subClause(sub, 5, subClauseTable(type), me, showNsfw),
|
||||
typeClause(type),
|
||||
whenClause(when, 'Item'),
|
||||
await filterClause(me, models, type),
|
||||
muteClause(me))}
|
||||
ORDER BY rank DESC
|
||||
OFFSET $3
|
||||
LIMIT $4`,
|
||||
orderBy: 'ORDER BY rank DESC'
|
||||
}, ...whenRange(when, from, to || decodedCursor.time), decodedCursor.offset, limit, ...subArr)
|
||||
} else {
|
||||
items = await itemQueryWithMeta({
|
||||
me,
|
||||
models,
|
||||
@ -413,7 +384,6 @@ export default {
|
||||
LIMIT $4`,
|
||||
orderBy: orderByClause(by || 'zaprank', me, models, type)
|
||||
}, ...whenRange(when, from, to || decodedCursor.time), decodedCursor.offset, limit, ...subArr)
|
||||
}
|
||||
break
|
||||
default:
|
||||
// sub so we know the default ranking
|
||||
|
@ -102,5 +102,5 @@ OneOneSeven117,issue,#1187,#1164,easy,,,,10k,OneOneSeven@stacker.news,2024-05-23
|
||||
tsmith123,pr,#1191,#134,medium,,,required small fix,225k,stickymarch60@walletofsatoshi.com,2024-05-28
|
||||
benalleng,helpfulness,#1191,#134,medium,,,did most of this before,100k,benalleng@mutiny.plus,2024-05-28
|
||||
cointastical,issue,#1191,#134,medium,,,,22k,cointastical@stacker.news,2024-05-28
|
||||
kravhen,pr,#1198,#1180,good-first-issue,,,required linting,18k,???,???
|
||||
kravhen,pr,#1198,#1180,good-first-issue,,,required linting,18k,nichro@getalby.com,2024-05-28
|
||||
OneOneSeven117,issue,#1198,#1180,good-first-issue,,,required linting,2k,OneOneSeven@stacker.news,2024-05-28
|
||||
|
|
@ -162,7 +162,7 @@ function AnonInfo () {
|
||||
|
||||
return (
|
||||
<AnonIcon
|
||||
className='ms-2 fill-theme-color' height={22} width={22}
|
||||
className='ms-2 fill-theme-color pointer' height={22} width={22}
|
||||
onClick={
|
||||
(e) =>
|
||||
showModal(onClose =>
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react'
|
||||
import { createContext, useCallback, useContext, useEffect, useMemo, useReducer, useRef } from 'react'
|
||||
import Modal from 'react-bootstrap/Modal'
|
||||
import BackArrow from '@/svgs/arrow-left-line.svg'
|
||||
import { useRouter } from 'next/router'
|
||||
@ -23,26 +23,27 @@ export function useShowModal () {
|
||||
}
|
||||
|
||||
export default function useModal () {
|
||||
const [modalContent, setModalContent] = useState(null)
|
||||
const [modalOptions, setModalOptions] = useState(null)
|
||||
const [modalStack, setModalStack] = useState([])
|
||||
const modalStack = useRef([])
|
||||
const [render, forceUpdate] = useReducer(x => x + 1, 0)
|
||||
|
||||
const getCurrentContent = useCallback(() => {
|
||||
return modalStack.current[modalStack.current.length - 1]
|
||||
}, [])
|
||||
|
||||
const onBack = useCallback(() => {
|
||||
if (modalStack.length === 0) {
|
||||
return setModalContent(null)
|
||||
}
|
||||
const previousModalContent = modalStack[modalStack.length - 1]
|
||||
setModalStack(modalStack.slice(0, -1))
|
||||
modalOptions?.onClose?.()
|
||||
return setModalContent(previousModalContent)
|
||||
}, [modalStack, setModalStack, modalOptions?.onClose])
|
||||
getCurrentContent()?.options?.onClose?.()
|
||||
modalStack.current.pop()
|
||||
forceUpdate()
|
||||
}, [])
|
||||
|
||||
// this is called on every navigation due to below useEffect
|
||||
const onClose = useCallback(() => {
|
||||
setModalContent(null)
|
||||
setModalStack(ms => ms.length > 0 ? [] : ms)
|
||||
modalOptions?.onClose?.()
|
||||
}, [setModalStack, setModalContent, modalOptions?.onClose])
|
||||
while (modalStack.current.length) {
|
||||
getCurrentContent()?.options?.onClose?.()
|
||||
modalStack.current.pop()
|
||||
}
|
||||
forceUpdate()
|
||||
}, [])
|
||||
|
||||
const router = useRouter()
|
||||
useEffect(() => {
|
||||
@ -51,45 +52,49 @@ export default function useModal () {
|
||||
}, [router.events, onClose])
|
||||
|
||||
const modal = useMemo(() => {
|
||||
if (modalContent === null) {
|
||||
if (modalStack.current.length === 0) {
|
||||
return null
|
||||
}
|
||||
const className = modalOptions?.fullScreen ? 'fullscreen' : ''
|
||||
|
||||
const content = getCurrentContent()
|
||||
const { overflow, keepOpen, fullScreen } = content.options || {}
|
||||
const className = fullScreen ? 'fullscreen' : ''
|
||||
|
||||
return (
|
||||
<Modal
|
||||
onHide={modalOptions?.keepOpen ? null : onClose} show={!!modalContent}
|
||||
onHide={keepOpen ? null : onClose} show={!!content}
|
||||
className={className}
|
||||
dialogClassName={className}
|
||||
contentClassName={className}
|
||||
>
|
||||
<div className='d-flex flex-row'>
|
||||
{modalOptions?.overflow &&
|
||||
{overflow &&
|
||||
<div className={'modal-btn modal-overflow ' + className}>
|
||||
<ActionDropdown>
|
||||
{modalOptions.overflow}
|
||||
{overflow}
|
||||
</ActionDropdown>
|
||||
</div>}
|
||||
{modalStack.length > 0 ? <div className='modal-btn modal-back' onClick={onBack}><BackArrow width={18} height={18} className='fill-white' /></div> : null}
|
||||
{modalStack.current.length > 1 ? <div className='modal-btn modal-back' onClick={onBack}><BackArrow width={18} height={18} className='fill-white' /></div> : null}
|
||||
<div className={'modal-btn modal-close ' + className} onClick={onClose}>X</div>
|
||||
</div>
|
||||
<Modal.Body className={className}>
|
||||
{modalContent}
|
||||
{content.node}
|
||||
</Modal.Body>
|
||||
</Modal>
|
||||
)
|
||||
}, [modalContent, onClose, modalOptions, onBack, modalStack])
|
||||
}, [render])
|
||||
|
||||
const showModal = useCallback(
|
||||
(getContent, options) => {
|
||||
if (modalContent) {
|
||||
const ref = { node: getContent(onClose), options }
|
||||
if (options?.replaceModal) {
|
||||
setModalStack(stack => ([]))
|
||||
} else setModalStack(stack => ([...stack, modalContent]))
|
||||
modalStack.current = [ref]
|
||||
} else {
|
||||
modalStack.current.push(ref)
|
||||
}
|
||||
setModalOptions(options)
|
||||
setModalContent(getContent(onClose))
|
||||
forceUpdate()
|
||||
},
|
||||
[modalContent, onClose]
|
||||
[onClose]
|
||||
)
|
||||
|
||||
return [modal, showModal]
|
||||
|
@ -244,8 +244,8 @@ export default memo(function Text ({ rel, imgproxyUrls, children, tab, itemId, o
|
||||
paddingRight: '15px'
|
||||
}
|
||||
|
||||
try {
|
||||
const { provider, id, meta } = parseEmbedUrl(href)
|
||||
|
||||
// Youtube video embed
|
||||
if (provider === 'youtube') {
|
||||
return (
|
||||
@ -275,6 +275,9 @@ export default memo(function Text ({ rel, imgproxyUrls, children, tab, itemId, o
|
||||
</div>
|
||||
)
|
||||
}
|
||||
} catch {
|
||||
// ignore invalid URLs
|
||||
}
|
||||
|
||||
// assume the link is an image which will fallback to link if it's not
|
||||
return <Img src={href} rel={rel ?? UNKNOWN_LINK_REL} {...props}>{children}</Img>
|
||||
|
@ -36,7 +36,7 @@ export const ITEM_SPAM_INTERVAL = '10m'
|
||||
export const ANON_ITEM_SPAM_INTERVAL = '0'
|
||||
export const INV_PENDING_LIMIT = 100
|
||||
export const BALANCE_LIMIT_MSATS = 100000000 // 100k sat
|
||||
export const SN_USER_IDS = [616, 6030, 946, 4502, 27]
|
||||
export const SN_USER_IDS = [616, 6030, 4502, 27]
|
||||
export const SN_NO_REWARDS_IDS = [27, 4502]
|
||||
export const ANON_INV_PENDING_LIMIT = 1000
|
||||
export const ANON_BALANCE_LIMIT_MSATS = 0 // disable
|
||||
|
Loading…
x
Reference in New Issue
Block a user