import { init as initNostrLogin, launch as launchNostrLoginDialog } from 'nostr-login' import React, { useEffect, useState } from 'react' import { Link } from 'react-router-dom' import { Banner } from '../components/Banner' import { ZapPopUp } from '../components/Zap' import { useAppDispatch, useAppSelector, useBodyScrollDisable, useDidMount, useNDKContext } from '../hooks' import { appRoutes } from '../routes' import { setAuth, setUser } from '../store/reducers/user' import mainStyles from '../styles//main.module.scss' import navStyles from '../styles/nav.module.scss' import '../styles/popup.css' import { npubToHex } from '../utils' import logo from '../assets/img/DEG Mods Logo With Text.svg' import placeholder from '../assets/img/DEG Mods Default PP.png' import { resetUserWot } from 'store/reducers/wot' export const Header = () => { const dispatch = useAppDispatch() const { findMetadata } = useNDKContext() 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(() => { initNostrLogin({ darkMode: true, noBanner: true, methods: ['extension'], onAuth: (npub, opts) => { if (opts.type === 'logout') { dispatch(setAuth(null)) dispatch(setUser(null)) dispatch(resetUserWot()) } else { dispatch( setAuth({ method: opts.method, localNsec: opts.localNsec }) ) dispatch( setUser({ npub, pubkey: npubToHex(npub)! }) ) findMetadata(npub).then((userProfile) => { if (userProfile) { dispatch( setUser({ npub, pubkey: npubToHex(npub)!, ...userProfile }) ) } }) } } }) }, [dispatch, findMetadata]) const handleLogin = () => { handleOpen() launchNostrLoginDialog() } return (
Submit Mod Write Settings {!userState.auth && ( <> Login )} {userState.auth && userState.user && (
{userState.user.image && ( Profile Avatar )} {userState.user.name || userState.user.displayName || userState.user.npub}
)}
Games Mods About Blog
) } const TipButtonWithDialog = React.memo(() => { const [adminNpub, setAdminNpub] = useState(null) const [isOpen, setIsOpen] = useState(false) useBodyScrollDisable(isOpen) useDidMount(async () => { const adminNpubs = import.meta.env.VITE_ADMIN_NPUBS.split(',') setAdminNpub(adminNpubs[0]) }) return ( <> setIsOpen(true)} > Tip {isOpen && adminNpub && ( setIsOpen(false)} labelDescriptionMain={

If you don't want the development and maintenance of DEG Mods to stop, then a tip helps!

} lastNode={

DEG Mod's Silent Payment Bitcoin Address (Be careful.{' '} Learn more ):
sp1qq205tj23sq3z6qjxt5ts5ps8gdwcrkwypej3h2z2hdclmaptl25xxqjfqhc2de4gaxprgm0yqwfr737swpvvmrph9ctkeyk60knz6xpjhqumafrd

} /> )} ) }) const RegisterButtonWithDialog = () => { const [showPopUp, setShowPopUp] = useState(false) useBodyScrollDisable(showPopUp) return ( <> setShowPopUp(true)} > Register {showPopUp && (

Create an account via

setShowPopUp(false)} >

Once you create your "account" on any of these, come back and click login, then sign-in with extension. Here's a quick video guide, and here's a{' '} guide post {' '} to help with this process.

Nostr Connect Nostr Connect (Firefox) Keys.Band nos2x

Q: Why can't I create an account normally?
A: DEG Mods can't ban you or delete your content (we can only hide you), and the consequence of that is this kind of registration/login system.

Warning: Make sure you backup your private key somewhere safe. If you lose it or it gets leaked, we actually can't help you.

or

Once you create your "account" on any of these, come back and click login, then sign-in with extension.

Nostore Browser Extension
)} ) }