Merge branch 'staging' into ndk-refactor
This commit is contained in:
commit
ffc7b60363
@ -4,7 +4,12 @@ import { QRCodeSVG } from 'qrcode.react'
|
|||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
import { Link } from 'react-router-dom'
|
import { Link } from 'react-router-dom'
|
||||||
import { toast } from 'react-toastify'
|
import { toast } from 'react-toastify'
|
||||||
import { useAppSelector, useDidMount, useNDKContext } from '../hooks'
|
import {
|
||||||
|
useAppSelector,
|
||||||
|
useBodyScrollDisable,
|
||||||
|
useDidMount,
|
||||||
|
useNDKContext
|
||||||
|
} from '../hooks'
|
||||||
import { appRoutes, getProfilePageRoute } from '../routes'
|
import { appRoutes, getProfilePageRoute } from '../routes'
|
||||||
import '../styles/author.css'
|
import '../styles/author.css'
|
||||||
import '../styles/innerPage.css'
|
import '../styles/innerPage.css'
|
||||||
@ -254,6 +259,8 @@ export const ProfileQRButtonWithPopUp = ({
|
|||||||
}: QRButtonWithPopUpProps) => {
|
}: QRButtonWithPopUpProps) => {
|
||||||
const [isOpen, setIsOpen] = useState(false)
|
const [isOpen, setIsOpen] = useState(false)
|
||||||
|
|
||||||
|
useBodyScrollDisable(isOpen)
|
||||||
|
|
||||||
const nprofile = nip19.nprofileEncode({
|
const nprofile = nip19.nprofileEncode({
|
||||||
pubkey
|
pubkey
|
||||||
})
|
})
|
||||||
@ -335,6 +342,8 @@ type ZapButtonWithPopUpProps = {
|
|||||||
const ZapButtonWithPopUp = ({ pubkey }: ZapButtonWithPopUpProps) => {
|
const ZapButtonWithPopUp = ({ pubkey }: ZapButtonWithPopUpProps) => {
|
||||||
const [isOpen, setIsOpen] = useState(false)
|
const [isOpen, setIsOpen] = useState(false)
|
||||||
|
|
||||||
|
useBodyScrollDisable(isOpen)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div
|
<div
|
||||||
|
@ -6,3 +6,4 @@ export * from './useMuteLists'
|
|||||||
export * from './useNSFWList'
|
export * from './useNSFWList'
|
||||||
export * from './useReactions'
|
export * from './useReactions'
|
||||||
export * from './useNDKContext'
|
export * from './useNDKContext'
|
||||||
|
export * from './useScrollDisable'
|
||||||
|
11
src/hooks/useScrollDisable.ts
Normal file
11
src/hooks/useScrollDisable.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import { useEffect } from 'react'
|
||||||
|
|
||||||
|
export const useBodyScrollDisable = (disable: boolean) => {
|
||||||
|
useEffect(() => {
|
||||||
|
if (disable) document.body.style.overflow = 'hidden'
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
document.body.style.overflow = ''
|
||||||
|
}
|
||||||
|
}, [disable])
|
||||||
|
}
|
@ -9,6 +9,7 @@ import { ZapPopUp } from '../components/Zap'
|
|||||||
import {
|
import {
|
||||||
useAppDispatch,
|
useAppDispatch,
|
||||||
useAppSelector,
|
useAppSelector,
|
||||||
|
useBodyScrollDisable,
|
||||||
useDidMount,
|
useDidMount,
|
||||||
useNDKContext
|
useNDKContext
|
||||||
} from '../hooks'
|
} from '../hooks'
|
||||||
@ -26,6 +27,18 @@ export const Header = () => {
|
|||||||
const { findMetadata } = useNDKContext()
|
const { findMetadata } = useNDKContext()
|
||||||
const userState = useAppSelector((state) => state.user)
|
const userState = useAppSelector((state) => state.user)
|
||||||
|
|
||||||
|
// Track nostr-login extension modal open state
|
||||||
|
const [isOpen, setIsOpen] = useState(false)
|
||||||
|
const handleOpen = () => setIsOpen(true)
|
||||||
|
const handleClose = () => setIsOpen(false)
|
||||||
|
useEffect(() => {
|
||||||
|
window.addEventListener('nlCloseModal', handleClose)
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener('nlCloseModal', handleClose)
|
||||||
|
}
|
||||||
|
}, [])
|
||||||
|
useBodyScrollDisable(isOpen)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
initNostrLogin({
|
initNostrLogin({
|
||||||
darkMode: true,
|
darkMode: true,
|
||||||
@ -65,6 +78,7 @@ export const Header = () => {
|
|||||||
}, [dispatch, findMetadata])
|
}, [dispatch, findMetadata])
|
||||||
|
|
||||||
const handleLogin = () => {
|
const handleLogin = () => {
|
||||||
|
handleOpen()
|
||||||
launchNostrLoginDialog()
|
launchNostrLoginDialog()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -259,6 +273,8 @@ const TipButtonWithDialog = React.memo(() => {
|
|||||||
const [adminNpub, setAdminNpub] = useState<string | null>(null)
|
const [adminNpub, setAdminNpub] = useState<string | null>(null)
|
||||||
const [isOpen, setIsOpen] = useState(false)
|
const [isOpen, setIsOpen] = useState(false)
|
||||||
|
|
||||||
|
useBodyScrollDisable(isOpen)
|
||||||
|
|
||||||
useDidMount(async () => {
|
useDidMount(async () => {
|
||||||
const adminNpubs = import.meta.env.VITE_ADMIN_NPUBS.split(',')
|
const adminNpubs = import.meta.env.VITE_ADMIN_NPUBS.split(',')
|
||||||
setAdminNpub(adminNpubs[0])
|
setAdminNpub(adminNpubs[0])
|
||||||
@ -320,6 +336,8 @@ const TipButtonWithDialog = React.memo(() => {
|
|||||||
const RegisterButtonWithDialog = () => {
|
const RegisterButtonWithDialog = () => {
|
||||||
const [showPopUp, setShowPopUp] = useState(false)
|
const [showPopUp, setShowPopUp] = useState(false)
|
||||||
|
|
||||||
|
useBodyScrollDisable(showPopUp)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<a
|
<a
|
||||||
|
@ -11,7 +11,12 @@ import { toast } from 'react-toastify'
|
|||||||
import { BlogCard } from '../../components/BlogCard'
|
import { BlogCard } from '../../components/BlogCard'
|
||||||
import { LoadingSpinner } from '../../components/LoadingSpinner'
|
import { LoadingSpinner } from '../../components/LoadingSpinner'
|
||||||
import { ProfileSection } from '../../components/ProfileSection'
|
import { ProfileSection } from '../../components/ProfileSection'
|
||||||
import { useAppSelector, useDidMount, useNDKContext } from '../../hooks'
|
import {
|
||||||
|
useAppSelector,
|
||||||
|
useBodyScrollDisable,
|
||||||
|
useDidMount,
|
||||||
|
useNDKContext
|
||||||
|
} from '../../hooks'
|
||||||
import { getGamePageRoute, getModsEditPageRoute } from '../../routes'
|
import { getGamePageRoute, getModsEditPageRoute } from '../../routes'
|
||||||
import '../../styles/comments.css'
|
import '../../styles/comments.css'
|
||||||
import '../../styles/downloads.css'
|
import '../../styles/downloads.css'
|
||||||
@ -220,6 +225,8 @@ const Game = ({ naddr, game, author, aTag }: GameProps) => {
|
|||||||
const [isBlocked, setIsBlocked] = useState(false)
|
const [isBlocked, setIsBlocked] = useState(false)
|
||||||
const [isAddedToNSFW, setIsAddedToNSFW] = useState(false)
|
const [isAddedToNSFW, setIsAddedToNSFW] = useState(false)
|
||||||
|
|
||||||
|
useBodyScrollDisable(showReportPopUp)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (userState.auth && userState.user?.pubkey) {
|
if (userState.auth && userState.user?.pubkey) {
|
||||||
const pubkey = userState.user.pubkey as string
|
const pubkey = userState.user.pubkey as string
|
||||||
|
@ -1,7 +1,13 @@
|
|||||||
import { NDKEvent } from '@nostr-dev-kit/ndk'
|
import { NDKEvent } from '@nostr-dev-kit/ndk'
|
||||||
import { ZapPopUp } from 'components/Zap'
|
import { ZapPopUp } from 'components/Zap'
|
||||||
import { formatDate } from 'date-fns'
|
import { formatDate } from 'date-fns'
|
||||||
import { useAppSelector, useDidMount, useNDKContext, useReactions } from 'hooks'
|
import {
|
||||||
|
useAppSelector,
|
||||||
|
useBodyScrollDisable,
|
||||||
|
useDidMount,
|
||||||
|
useNDKContext,
|
||||||
|
useReactions
|
||||||
|
} from 'hooks'
|
||||||
import { useComments } from 'hooks/useComments'
|
import { useComments } from 'hooks/useComments'
|
||||||
import { Event, kinds, nip19, UnsignedEvent } from 'nostr-tools'
|
import { Event, kinds, nip19, UnsignedEvent } from 'nostr-tools'
|
||||||
import React, {
|
import React, {
|
||||||
@ -495,6 +501,8 @@ const Zap = (props: Event) => {
|
|||||||
const userState = useAppSelector((state) => state.user)
|
const userState = useAppSelector((state) => state.user)
|
||||||
const { getTotalZapAmount } = useNDKContext()
|
const { getTotalZapAmount } = useNDKContext()
|
||||||
|
|
||||||
|
useBodyScrollDisable(isOpen)
|
||||||
|
|
||||||
useDidMount(() => {
|
useDidMount(() => {
|
||||||
getTotalZapAmount(
|
getTotalZapAmount(
|
||||||
props.pubkey,
|
props.pubkey,
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
import { ZapSplit } from 'components/Zap'
|
import { ZapSplit } from 'components/Zap'
|
||||||
import { useAppSelector, useDidMount, useNDKContext } from 'hooks'
|
import {
|
||||||
|
useAppSelector,
|
||||||
|
useBodyScrollDisable,
|
||||||
|
useDidMount,
|
||||||
|
useNDKContext
|
||||||
|
} from 'hooks'
|
||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
import { toast } from 'react-toastify'
|
import { toast } from 'react-toastify'
|
||||||
import { ModDetails } from 'types'
|
import { ModDetails } from 'types'
|
||||||
@ -17,6 +22,8 @@ export const Zap = ({ modDetails }: ZapProps) => {
|
|||||||
const userState = useAppSelector((state) => state.user)
|
const userState = useAppSelector((state) => state.user)
|
||||||
const { getTotalZapAmount } = useNDKContext()
|
const { getTotalZapAmount } = useNDKContext()
|
||||||
|
|
||||||
|
useBodyScrollDisable(isOpen)
|
||||||
|
|
||||||
useDidMount(() => {
|
useDidMount(() => {
|
||||||
getTotalZapAmount(
|
getTotalZapAmount(
|
||||||
modDetails.author,
|
modDetails.author,
|
||||||
|
@ -143,3 +143,10 @@
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
color: rgba(255, 255, 255, 0.25);
|
color: rgba(255, 255, 255, 0.25);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.IBMSMSMBSSTagsTag.IBMSMSMBSSTagsTagNSFW.IBMSMSMBSSTagsTagNSFWCard {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 10px;
|
||||||
|
right: 10px;
|
||||||
|
backdrop-filter: blur(10px);
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user