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'
|
return 'ORDER BY "Item".created_at DESC, "Item".id DESC'
|
||||||
}
|
}
|
||||||
|
|
||||||
if (me) {
|
if (me && sort === 'hot') {
|
||||||
if (sort === 'top') {
|
return `ORDER BY COALESCE(
|
||||||
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 {
|
|
||||||
return `ORDER BY COALESCE(
|
|
||||||
personal_hot_score,
|
personal_hot_score,
|
||||||
${orderByNumerator(models, 0)}/POWER(GREATEST(3, EXTRACT(EPOCH FROM (now_utc() - "Item".created_at))/3600), 1.3)) DESC NULLS LAST,
|
${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`
|
"Item".msats DESC, ("Item".freebie IS FALSE) DESC, "Item".id DESC`
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (sort === 'top') {
|
if (sort === 'top') {
|
||||||
return `ORDER BY ${orderByNumerator(models, 0)} DESC NULLS LAST, "Item".msats DESC, ("Item".freebie IS FALSE) DESC, "Item".id DESC`
|
return `ORDER BY ${orderByNumerator(models, 0)} DESC NULLS LAST, "Item".msats DESC, ("Item".freebie IS FALSE) DESC, "Item".id DESC`
|
||||||
@ -373,32 +366,10 @@ export default {
|
|||||||
}, decodedCursor.time, decodedCursor.offset, limit, ...subArr)
|
}, decodedCursor.time, decodedCursor.offset, limit, ...subArr)
|
||||||
break
|
break
|
||||||
case 'top':
|
case 'top':
|
||||||
if (me && (!by || by === 'zaprank') && (when === 'day' || when === 'week')) {
|
items = await itemQueryWithMeta({
|
||||||
// personalized zaprank only goes back 7 days
|
me,
|
||||||
items = await itemQueryWithMeta({
|
models,
|
||||||
me,
|
query: `
|
||||||
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,
|
|
||||||
query: `
|
|
||||||
${selectClause(type)}
|
${selectClause(type)}
|
||||||
${relationClause(type)}
|
${relationClause(type)}
|
||||||
${whereClause(
|
${whereClause(
|
||||||
@ -411,9 +382,8 @@ export default {
|
|||||||
${orderByClause(by || 'zaprank', me, models, type)}
|
${orderByClause(by || 'zaprank', me, models, type)}
|
||||||
OFFSET $3
|
OFFSET $3
|
||||||
LIMIT $4`,
|
LIMIT $4`,
|
||||||
orderBy: orderByClause(by || 'zaprank', me, models, type)
|
orderBy: orderByClause(by || 'zaprank', me, models, type)
|
||||||
}, ...whenRange(when, from, to || decodedCursor.time), decodedCursor.offset, limit, ...subArr)
|
}, ...whenRange(when, from, to || decodedCursor.time), decodedCursor.offset, limit, ...subArr)
|
||||||
}
|
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
// sub so we know the default ranking
|
// 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
|
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
|
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
|
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
|
OneOneSeven117,issue,#1198,#1180,good-first-issue,,,required linting,2k,OneOneSeven@stacker.news,2024-05-28
|
||||||
|
|
@ -162,7 +162,7 @@ function AnonInfo () {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<AnonIcon
|
<AnonIcon
|
||||||
className='ms-2 fill-theme-color' height={22} width={22}
|
className='ms-2 fill-theme-color pointer' height={22} width={22}
|
||||||
onClick={
|
onClick={
|
||||||
(e) =>
|
(e) =>
|
||||||
showModal(onClose =>
|
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 Modal from 'react-bootstrap/Modal'
|
||||||
import BackArrow from '@/svgs/arrow-left-line.svg'
|
import BackArrow from '@/svgs/arrow-left-line.svg'
|
||||||
import { useRouter } from 'next/router'
|
import { useRouter } from 'next/router'
|
||||||
@ -23,26 +23,27 @@ export function useShowModal () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function useModal () {
|
export default function useModal () {
|
||||||
const [modalContent, setModalContent] = useState(null)
|
const modalStack = useRef([])
|
||||||
const [modalOptions, setModalOptions] = useState(null)
|
const [render, forceUpdate] = useReducer(x => x + 1, 0)
|
||||||
const [modalStack, setModalStack] = useState([])
|
|
||||||
|
const getCurrentContent = useCallback(() => {
|
||||||
|
return modalStack.current[modalStack.current.length - 1]
|
||||||
|
}, [])
|
||||||
|
|
||||||
const onBack = useCallback(() => {
|
const onBack = useCallback(() => {
|
||||||
if (modalStack.length === 0) {
|
getCurrentContent()?.options?.onClose?.()
|
||||||
return setModalContent(null)
|
modalStack.current.pop()
|
||||||
}
|
forceUpdate()
|
||||||
const previousModalContent = modalStack[modalStack.length - 1]
|
}, [])
|
||||||
setModalStack(modalStack.slice(0, -1))
|
|
||||||
modalOptions?.onClose?.()
|
|
||||||
return setModalContent(previousModalContent)
|
|
||||||
}, [modalStack, setModalStack, modalOptions?.onClose])
|
|
||||||
|
|
||||||
// this is called on every navigation due to below useEffect
|
// this is called on every navigation due to below useEffect
|
||||||
const onClose = useCallback(() => {
|
const onClose = useCallback(() => {
|
||||||
setModalContent(null)
|
while (modalStack.current.length) {
|
||||||
setModalStack(ms => ms.length > 0 ? [] : ms)
|
getCurrentContent()?.options?.onClose?.()
|
||||||
modalOptions?.onClose?.()
|
modalStack.current.pop()
|
||||||
}, [setModalStack, setModalContent, modalOptions?.onClose])
|
}
|
||||||
|
forceUpdate()
|
||||||
|
}, [])
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -51,45 +52,49 @@ export default function useModal () {
|
|||||||
}, [router.events, onClose])
|
}, [router.events, onClose])
|
||||||
|
|
||||||
const modal = useMemo(() => {
|
const modal = useMemo(() => {
|
||||||
if (modalContent === null) {
|
if (modalStack.current.length === 0) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
const className = modalOptions?.fullScreen ? 'fullscreen' : ''
|
|
||||||
|
const content = getCurrentContent()
|
||||||
|
const { overflow, keepOpen, fullScreen } = content.options || {}
|
||||||
|
const className = fullScreen ? 'fullscreen' : ''
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
onHide={modalOptions?.keepOpen ? null : onClose} show={!!modalContent}
|
onHide={keepOpen ? null : onClose} show={!!content}
|
||||||
className={className}
|
className={className}
|
||||||
dialogClassName={className}
|
dialogClassName={className}
|
||||||
contentClassName={className}
|
contentClassName={className}
|
||||||
>
|
>
|
||||||
<div className='d-flex flex-row'>
|
<div className='d-flex flex-row'>
|
||||||
{modalOptions?.overflow &&
|
{overflow &&
|
||||||
<div className={'modal-btn modal-overflow ' + className}>
|
<div className={'modal-btn modal-overflow ' + className}>
|
||||||
<ActionDropdown>
|
<ActionDropdown>
|
||||||
{modalOptions.overflow}
|
{overflow}
|
||||||
</ActionDropdown>
|
</ActionDropdown>
|
||||||
</div>}
|
</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 className={'modal-btn modal-close ' + className} onClick={onClose}>X</div>
|
||||||
</div>
|
</div>
|
||||||
<Modal.Body className={className}>
|
<Modal.Body className={className}>
|
||||||
{modalContent}
|
{content.node}
|
||||||
</Modal.Body>
|
</Modal.Body>
|
||||||
</Modal>
|
</Modal>
|
||||||
)
|
)
|
||||||
}, [modalContent, onClose, modalOptions, onBack, modalStack])
|
}, [render])
|
||||||
|
|
||||||
const showModal = useCallback(
|
const showModal = useCallback(
|
||||||
(getContent, options) => {
|
(getContent, options) => {
|
||||||
if (modalContent) {
|
const ref = { node: getContent(onClose), options }
|
||||||
if (options?.replaceModal) {
|
if (options?.replaceModal) {
|
||||||
setModalStack(stack => ([]))
|
modalStack.current = [ref]
|
||||||
} else setModalStack(stack => ([...stack, modalContent]))
|
} else {
|
||||||
|
modalStack.current.push(ref)
|
||||||
}
|
}
|
||||||
setModalOptions(options)
|
forceUpdate()
|
||||||
setModalContent(getContent(onClose))
|
|
||||||
},
|
},
|
||||||
[modalContent, onClose]
|
[onClose]
|
||||||
)
|
)
|
||||||
|
|
||||||
return [modal, showModal]
|
return [modal, showModal]
|
||||||
|
@ -244,36 +244,39 @@ export default memo(function Text ({ rel, imgproxyUrls, children, tab, itemId, o
|
|||||||
paddingRight: '15px'
|
paddingRight: '15px'
|
||||||
}
|
}
|
||||||
|
|
||||||
const { provider, id, meta } = parseEmbedUrl(href)
|
try {
|
||||||
|
const { provider, id, meta } = parseEmbedUrl(href)
|
||||||
// Youtube video embed
|
// Youtube video embed
|
||||||
if (provider === 'youtube') {
|
if (provider === 'youtube') {
|
||||||
return (
|
return (
|
||||||
<div style={videoWrapperStyles}>
|
<div style={videoWrapperStyles}>
|
||||||
<YouTube
|
<YouTube
|
||||||
videoId={id} className={styles.videoContainer} opts={{
|
videoId={id} className={styles.videoContainer} opts={{
|
||||||
playerVars: {
|
playerVars: {
|
||||||
start: meta?.start || 0
|
start: meta?.start || 0
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Rumble video embed
|
|
||||||
if (provider === 'rumble') {
|
|
||||||
return (
|
|
||||||
<div style={videoWrapperStyles}>
|
|
||||||
<div className={styles.videoContainer}>
|
|
||||||
<iframe
|
|
||||||
title='Rumble Video'
|
|
||||||
allowFullScreen=''
|
|
||||||
src={meta?.href}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
)
|
||||||
)
|
}
|
||||||
|
|
||||||
|
// Rumble video embed
|
||||||
|
if (provider === 'rumble') {
|
||||||
|
return (
|
||||||
|
<div style={videoWrapperStyles}>
|
||||||
|
<div className={styles.videoContainer}>
|
||||||
|
<iframe
|
||||||
|
title='Rumble Video'
|
||||||
|
allowFullScreen=''
|
||||||
|
src={meta?.href}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
// ignore invalid URLs
|
||||||
}
|
}
|
||||||
|
|
||||||
// assume the link is an image which will fallback to link if it's not
|
// assume the link is an image which will fallback to link if it's not
|
||||||
|
@ -36,7 +36,7 @@ export const ITEM_SPAM_INTERVAL = '10m'
|
|||||||
export const ANON_ITEM_SPAM_INTERVAL = '0'
|
export const ANON_ITEM_SPAM_INTERVAL = '0'
|
||||||
export const INV_PENDING_LIMIT = 100
|
export const INV_PENDING_LIMIT = 100
|
||||||
export const BALANCE_LIMIT_MSATS = 100000000 // 100k sat
|
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 SN_NO_REWARDS_IDS = [27, 4502]
|
||||||
export const ANON_INV_PENDING_LIMIT = 1000
|
export const ANON_INV_PENDING_LIMIT = 1000
|
||||||
export const ANON_BALANCE_LIMIT_MSATS = 0 // disable
|
export const ANON_BALANCE_LIMIT_MSATS = 0 // disable
|
||||||
|
Loading…
x
Reference in New Issue
Block a user