Compare commits
4 Commits
1d154ec9b5
...
9f79ff1f89
Author | SHA1 | Date | |
---|---|---|---|
|
9f79ff1f89 | ||
|
e7e7cbff0a | ||
|
e6b825dafe | ||
|
91a0d1ccd7 |
@ -87,6 +87,12 @@ OPENSEARCH_MODEL_ID=
|
||||
# prisma db url
|
||||
DATABASE_URL="postgresql://sn:password@db:5432/stackernews?schema=public"
|
||||
|
||||
# polling intervals
|
||||
NEXT_PUBLIC_FAST_POLL_INTERVAL=1000
|
||||
NEXT_PUBLIC_NORMAL_POLL_INTERVAL=30000
|
||||
NEXT_PUBLIC_LONG_POLL_INTERVAL=60000
|
||||
NEXT_PUBLIC_EXTRA_LONG_POLL_INTERVAL=300000
|
||||
|
||||
###################
|
||||
# FOR DOCKER ONLY #
|
||||
###################
|
||||
|
4
.github/pull_request_template.md
vendored
4
.github/pull_request_template.md
vendored
@ -52,3 +52,7 @@ If changes were requested, request a new review when you incorporated the feedba
|
||||
|
||||
<!-- You should be able to use the mobile browser emulator in your browser to test this. -->
|
||||
- [ ] For frontend changes: Tested on mobile?
|
||||
|
||||
<!-- New env vars need to be called out
|
||||
so they can be properly configured for prod. -->
|
||||
- [ ] Did you introduce any new environment variables? If so, call them out explicitly in the PR description.
|
||||
|
@ -161,6 +161,26 @@ export default {
|
||||
users
|
||||
}
|
||||
},
|
||||
myMutedUsers: async (parent, { cursor }, { models, me }) => {
|
||||
if (!me) {
|
||||
throw new GraphQLError('You must be logged in to view muted users', { extensions: { code: 'UNAUTHENTICATED' } })
|
||||
}
|
||||
|
||||
const decodedCursor = decodeCursor(cursor)
|
||||
const users = await models.$queryRaw`
|
||||
SELECT users.*
|
||||
FROM "Mute"
|
||||
JOIN users ON "Mute"."mutedId" = users.id
|
||||
WHERE "Mute"."muterId" = ${me.id}
|
||||
OFFSET ${decodedCursor.offset}
|
||||
LIMIT ${LIMIT}
|
||||
`
|
||||
|
||||
return {
|
||||
cursor: users.length === LIMIT ? nextCursorEncoded(decodedCursor) : null,
|
||||
users
|
||||
}
|
||||
},
|
||||
topCowboys: async (parent, { cursor }, { models, me }) => {
|
||||
const decodedCursor = decodeCursor(cursor)
|
||||
const range = whenRange('forever')
|
||||
|
@ -13,6 +13,7 @@ export default gql`
|
||||
userSuggestions(q: String, limit: Limit): [User!]!
|
||||
hasNewNotes: Boolean!
|
||||
mySubscribedUsers(cursor: String): Users!
|
||||
myMutedUsers(cursor: String): Users!
|
||||
}
|
||||
|
||||
type UsersNullable {
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { createContext, useContext, useMemo } from 'react'
|
||||
import { useQuery } from '@apollo/client'
|
||||
import { SSR } from '@/lib/constants'
|
||||
import { NORMAL_POLL_INTERVAL, SSR } from '@/lib/constants'
|
||||
import { BLOCK_HEIGHT } from '@/fragments/blockHeight'
|
||||
|
||||
export const BlockHeightContext = createContext({
|
||||
@ -14,7 +14,7 @@ export const BlockHeightProvider = ({ blockHeight, children }) => {
|
||||
...(SSR
|
||||
? {}
|
||||
: {
|
||||
pollInterval: 30000,
|
||||
pollInterval: NORMAL_POLL_INTERVAL,
|
||||
nextFetchPolicy: 'cache-and-network'
|
||||
})
|
||||
})
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { createContext, useContext, useMemo } from 'react'
|
||||
import { useQuery } from '@apollo/client'
|
||||
import { SSR } from '@/lib/constants'
|
||||
import { NORMAL_POLL_INTERVAL, SSR } from '@/lib/constants'
|
||||
import { CHAIN_FEE } from '@/fragments/chainFee'
|
||||
|
||||
export const ChainFeeContext = createContext({
|
||||
@ -14,7 +14,7 @@ export const ChainFeeProvider = ({ chainFee, children }) => {
|
||||
...(SSR
|
||||
? {}
|
||||
: {
|
||||
pollInterval: 30000,
|
||||
pollInterval: NORMAL_POLL_INTERVAL,
|
||||
nextFetchPolicy: 'cache-and-network'
|
||||
})
|
||||
})
|
||||
|
@ -4,7 +4,7 @@ import ActionTooltip from './action-tooltip'
|
||||
import Info from './info'
|
||||
import styles from './fee-button.module.css'
|
||||
import { gql, useQuery } from '@apollo/client'
|
||||
import { ANON_FEE_MULTIPLIER, SSR } from '@/lib/constants'
|
||||
import { ANON_FEE_MULTIPLIER, FAST_POLL_INTERVAL, SSR } from '@/lib/constants'
|
||||
import { numWithUnits } from '@/lib/format'
|
||||
import { useMe } from './me'
|
||||
import AnonIcon from '@/svgs/spy-fill.svg'
|
||||
@ -43,7 +43,7 @@ export function postCommentUseRemoteLineItems ({ parentId } = {}) {
|
||||
return function useRemoteLineItems () {
|
||||
const [line, setLine] = useState({})
|
||||
|
||||
const { data } = useQuery(query, SSR ? {} : { pollInterval: 1000, nextFetchPolicy: 'cache-and-network' })
|
||||
const { data } = useQuery(query, SSR ? {} : { pollInterval: FAST_POLL_INTERVAL, nextFetchPolicy: 'cache-and-network' })
|
||||
|
||||
useEffect(() => {
|
||||
const repetition = data?.itemRepetition
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { gql, useQuery } from '@apollo/client'
|
||||
import Link from 'next/link'
|
||||
import { RewardLine } from '@/pages/rewards'
|
||||
import { SSR } from '@/lib/constants'
|
||||
import { LONG_POLL_INTERVAL, SSR } from '@/lib/constants'
|
||||
|
||||
const REWARDS = gql`
|
||||
{
|
||||
@ -12,7 +12,7 @@ const REWARDS = gql`
|
||||
}`
|
||||
|
||||
export default function Rewards () {
|
||||
const { data } = useQuery(REWARDS, SSR ? { ssr: false } : { pollInterval: 60000, nextFetchPolicy: 'cache-and-network' })
|
||||
const { data } = useQuery(REWARDS, SSR ? { ssr: false } : { pollInterval: LONG_POLL_INTERVAL, nextFetchPolicy: 'cache-and-network' })
|
||||
const total = data?.rewards?.[0]?.total
|
||||
const time = data?.rewards?.[0]?.time
|
||||
return (
|
||||
|
@ -13,6 +13,7 @@ import Countdown from './countdown'
|
||||
import PayerData from './payer-data'
|
||||
import Bolt11Info from './bolt11-info'
|
||||
import { useWebLN } from './webln'
|
||||
import { FAST_POLL_INTERVAL } from '@/lib/constants'
|
||||
|
||||
export function Invoice ({ invoice, modal, onPayment, info, successVerb, webLn }) {
|
||||
const [expired, setExpired] = useState(new Date(invoice.expiredAt) <= new Date())
|
||||
@ -100,7 +101,7 @@ export function Invoice ({ invoice, modal, onPayment, info, successVerb, webLn }
|
||||
|
||||
const JITInvoice = ({ invoice: { id, hash, hmac, expiresAt }, onPayment, onCancel, onRetry }) => {
|
||||
const { data, loading, error } = useQuery(INVOICE, {
|
||||
pollInterval: 1000,
|
||||
pollInterval: FAST_POLL_INTERVAL,
|
||||
variables: { id }
|
||||
})
|
||||
const [retryError, setRetryError] = useState(0)
|
||||
@ -362,7 +363,7 @@ const waitForWebLNPayment = async ({ provider, invoice, pollInvoice, gqlCacheUpd
|
||||
clearInterval(interval)
|
||||
reject(err)
|
||||
}
|
||||
}, 1000)
|
||||
}, FAST_POLL_INTERVAL)
|
||||
})
|
||||
} catch (err) {
|
||||
undoUpdate?.()
|
||||
|
@ -9,7 +9,7 @@ import Qr, { QrSkeleton } from './qr'
|
||||
import styles from './lightning-auth.module.css'
|
||||
import BackIcon from '@/svgs/arrow-left-line.svg'
|
||||
import { useRouter } from 'next/router'
|
||||
import { SSR } from '@/lib/constants'
|
||||
import { FAST_POLL_INTERVAL, SSR } from '@/lib/constants'
|
||||
|
||||
function QrAuth ({ k1, encodedUrl, callbackUrl }) {
|
||||
const query = gql`
|
||||
@ -19,7 +19,7 @@ function QrAuth ({ k1, encodedUrl, callbackUrl }) {
|
||||
k1
|
||||
}
|
||||
}`
|
||||
const { data } = useQuery(query, SSR ? {} : { pollInterval: 1000, nextFetchPolicy: 'cache-and-network' })
|
||||
const { data } = useQuery(query, SSR ? {} : { pollInterval: FAST_POLL_INTERVAL, nextFetchPolicy: 'cache-and-network' })
|
||||
|
||||
useEffect(() => {
|
||||
if (data?.lnAuth?.pubkey) {
|
||||
|
@ -1,14 +1,14 @@
|
||||
import React, { useContext } from 'react'
|
||||
import { useQuery } from '@apollo/client'
|
||||
import { ME } from '@/fragments/users'
|
||||
import { SSR } from '@/lib/constants'
|
||||
import { FAST_POLL_INTERVAL, SSR } from '@/lib/constants'
|
||||
|
||||
export const MeContext = React.createContext({
|
||||
me: null
|
||||
})
|
||||
|
||||
export function MeProvider ({ me, children }) {
|
||||
const { data } = useQuery(ME, SSR ? {} : { pollInterval: 1000, nextFetchPolicy: 'cache-and-network' })
|
||||
const { data } = useQuery(ME, SSR ? {} : { pollInterval: FAST_POLL_INTERVAL, nextFetchPolicy: 'cache-and-network' })
|
||||
|
||||
return (
|
||||
<MeContext.Provider value={data?.me || me}>
|
||||
|
@ -1,10 +1,26 @@
|
||||
import { createContext, useContext } from 'react'
|
||||
import { useMutation } from '@apollo/client'
|
||||
import { gql } from 'graphql-tag'
|
||||
import Dropdown from 'react-bootstrap/Dropdown'
|
||||
import { useToast } from './toast'
|
||||
|
||||
const MuteUserContext = createContext(() => ({
|
||||
refetchQueries: []
|
||||
}))
|
||||
|
||||
export const MuteUserContextProvider = ({ children, value }) => {
|
||||
return (
|
||||
<MuteUserContext.Provider value={value}>
|
||||
{children}
|
||||
</MuteUserContext.Provider>
|
||||
)
|
||||
}
|
||||
|
||||
export const useMuteUserContext = () => useContext(MuteUserContext)
|
||||
|
||||
export default function MuteDropdownItem ({ user: { name, id, meMute } }) {
|
||||
const toaster = useToast()
|
||||
const { refetchQueries } = useMuteUserContext()
|
||||
const [toggleMute] = useMutation(
|
||||
gql`
|
||||
mutation toggleMute($id: ID!) {
|
||||
@ -12,6 +28,7 @@ export default function MuteDropdownItem ({ user: { name, id, meMute } }) {
|
||||
meMute
|
||||
}
|
||||
}`, {
|
||||
refetchQueries,
|
||||
update (cache, { data: { toggleMute } }) {
|
||||
cache.modify({
|
||||
id: `User:${id}`,
|
||||
|
@ -4,7 +4,7 @@ import { fixedDecimal } from '@/lib/format'
|
||||
import { useMe } from './me'
|
||||
import { PRICE } from '@/fragments/price'
|
||||
import { CURRENCY_SYMBOLS } from '@/lib/currency'
|
||||
import { SSR } from '@/lib/constants'
|
||||
import { NORMAL_POLL_INTERVAL, SSR } from '@/lib/constants'
|
||||
import { useBlockHeight } from './block-height'
|
||||
import { useChainFee } from './chain-fee'
|
||||
|
||||
@ -25,7 +25,7 @@ export function PriceProvider ({ price, children }) {
|
||||
...(SSR
|
||||
? {}
|
||||
: {
|
||||
pollInterval: 30000,
|
||||
pollInterval: NORMAL_POLL_INTERVAL,
|
||||
nextFetchPolicy: 'cache-and-network'
|
||||
})
|
||||
})
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { useRouter } from 'next/router'
|
||||
import { Select } from './form'
|
||||
import { SSR } from '@/lib/constants'
|
||||
import { EXTRA_LONG_POLL_INTERVAL, SSR } from '@/lib/constants'
|
||||
import { SUBS } from '@/fragments/subs'
|
||||
import { useQuery } from '@apollo/client'
|
||||
import { useEffect, useState } from 'react'
|
||||
@ -19,7 +19,7 @@ export function useSubs ({ prependSubs = [], sub, filterSubs = () => true, appen
|
||||
const { data } = useQuery(SUBS, SSR
|
||||
? {}
|
||||
: {
|
||||
pollInterval: 300000,
|
||||
pollInterval: EXTRA_LONG_POLL_INTERVAL,
|
||||
nextFetchPolicy: 'cache-and-network'
|
||||
})
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { HAS_NOTIFICATIONS } from '@/fragments/notifications'
|
||||
import { clearNotifications } from '@/lib/badge'
|
||||
import { SSR } from '@/lib/constants'
|
||||
import { NORMAL_POLL_INTERVAL, SSR } from '@/lib/constants'
|
||||
import { useQuery } from '@apollo/client'
|
||||
import React, { useContext } from 'react'
|
||||
|
||||
@ -11,7 +11,7 @@ export function HasNewNotesProvider ({ me, children }) {
|
||||
SSR
|
||||
? {}
|
||||
: {
|
||||
pollInterval: 30000,
|
||||
pollInterval: NORMAL_POLL_INTERVAL,
|
||||
nextFetchPolicy: 'cache-and-network',
|
||||
onCompleted: ({ hasNewNotes }) => {
|
||||
if (!hasNewNotes) {
|
||||
|
@ -226,6 +226,26 @@ export const MY_SUBSCRIBED_USERS = gql`
|
||||
}
|
||||
`
|
||||
|
||||
export const MY_MUTED_USERS = gql`
|
||||
query MyMutedUsers($cursor: String) {
|
||||
myMutedUsers(cursor: $cursor) {
|
||||
users {
|
||||
id
|
||||
name
|
||||
photoId
|
||||
meSubscriptionPosts
|
||||
meSubscriptionComments
|
||||
meMute
|
||||
|
||||
optional {
|
||||
streak
|
||||
}
|
||||
}
|
||||
cursor
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
export const TOP_USERS = gql`
|
||||
query TopUsers($cursor: String, $when: String, $from: String, $to: String, $by: String, ) {
|
||||
topUsers(cursor: $cursor, when: $when, from: $from, to: $to, by: $by) {
|
||||
|
@ -99,6 +99,19 @@ function getClient (uri) {
|
||||
}
|
||||
}
|
||||
},
|
||||
myMutedUsers: {
|
||||
keyArgs: false,
|
||||
merge (existing, incoming) {
|
||||
if (isFirstPage(incoming.cursor, existing?.users)) {
|
||||
return incoming
|
||||
}
|
||||
|
||||
return {
|
||||
cursor: incoming.cursor,
|
||||
users: [...(existing?.users || []), ...incoming.users]
|
||||
}
|
||||
}
|
||||
},
|
||||
userSuggestions: {
|
||||
keyArgs: ['q', 'limit'],
|
||||
merge (existing, incoming) {
|
||||
|
@ -126,3 +126,8 @@ export const ITEM_ALLOW_EDITS = [
|
||||
]
|
||||
|
||||
export const INVOICE_RETENTION_DAYS = 7
|
||||
|
||||
export const FAST_POLL_INTERVAL = Number(process.env.NEXT_PUBLIC_FAST_POLL_INTERVAL)
|
||||
export const NORMAL_POLL_INTERVAL = Number(process.env.NEXT_PUBLIC_NORMAL_POLL_INTERVAL)
|
||||
export const LONG_POLL_INTERVAL = Number(process.env.NEXT_PUBLIC_LONG_POLL_INTERVAL)
|
||||
export const EXTRA_LONG_POLL_INTERVAL = Number(process.env.NEXT_PUBLIC_EXTRA_LONG_POLL_INTERVAL)
|
||||
|
@ -4,7 +4,7 @@ import { QrSkeleton } from '@/components/qr'
|
||||
import { CenterLayout } from '@/components/layout'
|
||||
import { useRouter } from 'next/router'
|
||||
import { INVOICE } from '@/fragments/wallet'
|
||||
import { SSR } from '@/lib/constants'
|
||||
import { FAST_POLL_INTERVAL, SSR } from '@/lib/constants'
|
||||
import { getGetServerSideProps } from '@/api/ssrApollo'
|
||||
|
||||
// force SSR to include CSP nonces
|
||||
@ -15,7 +15,7 @@ export default function FullInvoice () {
|
||||
const { data, error } = useQuery(INVOICE, SSR
|
||||
? {}
|
||||
: {
|
||||
pollInterval: 1000,
|
||||
pollInterval: FAST_POLL_INTERVAL,
|
||||
variables: { id: router.query.id },
|
||||
nextFetchPolicy: 'cache-and-network'
|
||||
})
|
||||
|
@ -12,7 +12,7 @@ import { numWithUnits } from '@/lib/format'
|
||||
import PageLoading from '@/components/page-loading'
|
||||
import { useShowModal } from '@/components/modal'
|
||||
import dynamic from 'next/dynamic'
|
||||
import { SSR } from '@/lib/constants'
|
||||
import { FAST_POLL_INTERVAL, SSR } from '@/lib/constants'
|
||||
import { useToast } from '@/components/toast'
|
||||
import { useLightning } from '@/components/lightning'
|
||||
import { ListUsers } from '@/components/user-list'
|
||||
@ -94,7 +94,7 @@ export default function Rewards ({ ssrData }) {
|
||||
// only poll for updates to rewards and not leaderboard
|
||||
const { data: rewardsData } = useQuery(
|
||||
REWARDS,
|
||||
SSR ? {} : { pollInterval: 1000, nextFetchPolicy: 'cache-and-network' })
|
||||
SSR ? {} : { pollInterval: FAST_POLL_INTERVAL, nextFetchPolicy: 'cache-and-network' })
|
||||
const { data } = useQuery(REWARDS_FULL)
|
||||
const dat = useData(data, ssrData)
|
||||
|
||||
|
@ -41,7 +41,7 @@ function bech32encode (hexString) {
|
||||
export function SettingsHeader () {
|
||||
const router = useRouter()
|
||||
const pathParts = router.asPath.split('/').filter(segment => !!segment)
|
||||
const activeKey = pathParts.length === 1 ? 'general' : 'subscriptions'
|
||||
const activeKey = pathParts[1] ?? 'general'
|
||||
return (
|
||||
<>
|
||||
<h2 className='mb-2 text-start'>settings</h2>
|
||||
@ -59,6 +59,11 @@ export function SettingsHeader () {
|
||||
<Nav.Link eventKey='subscriptions'>subscriptions</Nav.Link>
|
||||
</Link>
|
||||
</Nav.Item>
|
||||
<Nav.Item>
|
||||
<Link href='/settings/mutes' passHref legacyBehavior>
|
||||
<Nav.Link eventKey='mutes'>muted stackers</Nav.Link>
|
||||
</Link>
|
||||
</Nav.Item>
|
||||
</Nav>
|
||||
</>
|
||||
)
|
||||
|
31
pages/settings/mutes/index.js
Normal file
31
pages/settings/mutes/index.js
Normal file
@ -0,0 +1,31 @@
|
||||
import { useMemo } from 'react'
|
||||
import { getGetServerSideProps } from '@/api/ssrApollo'
|
||||
import Layout from '@/components/layout'
|
||||
import UserList from '@/components/user-list'
|
||||
import { MY_MUTED_USERS } from '@/fragments/users'
|
||||
import { SettingsHeader } from '../index'
|
||||
import { MuteUserContextProvider } from '@/components/mute'
|
||||
|
||||
export const getServerSideProps = getGetServerSideProps({ query: MY_MUTED_USERS, authRequired: true })
|
||||
|
||||
export default function MyMutedUsers ({ ssrData }) {
|
||||
const muteUserContextValue = useMemo(() => ({ refetchQueries: ['MyMutedUsers'] }), [])
|
||||
return (
|
||||
<Layout>
|
||||
<div className='pb-3 w-100 mt-2'>
|
||||
<SettingsHeader />
|
||||
<div className='mb-4 text-muted'>Well now, reckon these here are the folks you've gone and silenced.</div>
|
||||
<MuteUserContextProvider value={muteUserContextValue}>
|
||||
<UserList
|
||||
ssrData={ssrData} query={MY_MUTED_USERS}
|
||||
destructureData={data => data.myMutedUsers}
|
||||
variables={{}}
|
||||
rank
|
||||
nymActionDropdown
|
||||
statCompsProp={[]}
|
||||
/>
|
||||
</MuteUserContextProvider>
|
||||
</div>
|
||||
</Layout>
|
||||
)
|
||||
}
|
@ -15,7 +15,7 @@ import { CREATE_WITHDRAWL, SEND_TO_LNADDR } from '@/fragments/wallet'
|
||||
import { getGetServerSideProps } from '@/api/ssrApollo'
|
||||
import { amountSchema, lnAddrSchema, withdrawlSchema } from '@/lib/validate'
|
||||
import Nav from 'react-bootstrap/Nav'
|
||||
import { BALANCE_LIMIT_MSATS, SSR } from '@/lib/constants'
|
||||
import { BALANCE_LIMIT_MSATS, FAST_POLL_INTERVAL, SSR } from '@/lib/constants'
|
||||
import { msatsToSats, numWithUnits } from '@/lib/format'
|
||||
import styles from '@/components/user-header.module.css'
|
||||
import HiddenWalletSummary from '@/components/hidden-wallet-summary'
|
||||
@ -327,7 +327,7 @@ function LnQRWith ({ k1, encodedUrl }) {
|
||||
k1
|
||||
}
|
||||
}`
|
||||
const { data } = useQuery(query, SSR ? {} : { pollInterval: 1000, nextFetchPolicy: 'cache-and-network' })
|
||||
const { data } = useQuery(query, SSR ? {} : { pollInterval: FAST_POLL_INTERVAL, nextFetchPolicy: 'cache-and-network' })
|
||||
|
||||
if (data?.lnWith?.withdrawalId) {
|
||||
router.push(`/withdrawals/${data.lnWith.withdrawalId}`)
|
||||
|
@ -6,7 +6,7 @@ import InvoiceStatus from '@/components/invoice-status'
|
||||
import { useRouter } from 'next/router'
|
||||
import { WITHDRAWL } from '@/fragments/wallet'
|
||||
import Link from 'next/link'
|
||||
import { SSR, INVOICE_RETENTION_DAYS } from '@/lib/constants'
|
||||
import { SSR, INVOICE_RETENTION_DAYS, FAST_POLL_INTERVAL } from '@/lib/constants'
|
||||
import { numWithUnits } from '@/lib/format'
|
||||
import Bolt11Info from '@/components/bolt11-info'
|
||||
import { datePivot, timeLeft } from '@/lib/time'
|
||||
@ -48,7 +48,7 @@ function LoadWithdrawl () {
|
||||
? {}
|
||||
: {
|
||||
variables: { id: router.query.id },
|
||||
pollInterval: 1000,
|
||||
pollInterval: FAST_POLL_INTERVAL,
|
||||
nextFetchPolicy: 'cache-and-network'
|
||||
})
|
||||
if (error) return <div>error</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user