chore: revert changes related to displaying nsecbunker connection string
All checks were successful
Release / build_and_release (push) Successful in 43s

This commit is contained in:
Sabir Hassan 2024-03-25 10:30:01 +05:00
parent b2a8cff907
commit a70d02b4ea
9 changed files with 9 additions and 136 deletions

View File

@ -17,19 +17,14 @@ import Username from '../username'
import { Link, useNavigate } from 'react-router-dom' import { Link, useNavigate } from 'react-router-dom'
import nostrichAvatar from '../../assets/images/avatar.png' import nostrichAvatar from '../../assets/images/avatar.png'
import nostrichLogo from '../../assets/images/nostr-logo.jpg' import nostrichLogo from '../../assets/images/nostr-logo.jpg'
import { import { NostrController } from '../../controllers'
appPrivateRoutes, import { appPublicRoutes, getProfileRoute } from '../../routes'
appPublicRoutes,
getProfileRoute
} from '../../routes'
import { import {
clearAuthToken, clearAuthToken,
saveNsecBunkerDelegatedKey, saveNsecBunkerDelegatedKey,
shorten shorten
} from '../../utils' } from '../../utils'
import styles from './style.module.scss' import styles from './style.module.scss'
import { NostrController } from '../../controllers'
import { LoginMethods } from '../../store/auth/types'
export const AppBar = () => { export const AppBar = () => {
const navigate = useNavigate() const navigate = useNavigate()
@ -73,8 +68,7 @@ export const AppBar = () => {
loggedIn: false, loggedIn: false,
usersPubkey: undefined, usersPubkey: undefined,
loginMethod: undefined, loginMethod: undefined,
nsecBunkerPubkey: undefined, nsecBunkerPubkey: undefined
nsecbunkerRelay: undefined
}) })
) )
@ -147,16 +141,6 @@ export const AppBar = () => {
> >
Profile Profile
</MenuItem> </MenuItem>
{authState.loginMethod === LoginMethods.nsecBunker && (
<MenuItem
onClick={() => navigate(appPrivateRoutes.nsecbunker)}
sx={{
justifyContent: 'center'
}}
>
Nsecbunker
</MenuItem>
)}
<Link <Link
to={appPublicRoutes.help} to={appPublicRoutes.help}
target='_blank' target='_blank'

View File

@ -2,6 +2,7 @@ import { Box, Button, TextField, Typography } from '@mui/material'
import { getPublicKey, nip19 } from 'nostr-tools' import { getPublicKey, nip19 } from 'nostr-tools'
import { useEffect, useState } from 'react' import { useEffect, useState } from 'react'
import { useDispatch } from 'react-redux' import { useDispatch } from 'react-redux'
import { useNavigate } from 'react-router-dom'
import { toast } from 'react-toastify' import { toast } from 'react-toastify'
import { LoadingSpinner } from '../../components/LoadingSpinner' import { LoadingSpinner } from '../../components/LoadingSpinner'
import { import {
@ -12,14 +13,12 @@ import {
import { import {
updateKeyPair, updateKeyPair,
updateLoginMethod, updateLoginMethod,
updateNsecbunkerPubkey, updateNsecbunkerPubkey
updateNsecbunkerRelay
} from '../../store/actions' } from '../../store/actions'
import { LoginMethods } from '../../store/auth/types' import { LoginMethods } from '../../store/auth/types'
import { Dispatch } from '../../store/store' import { Dispatch } from '../../store/store'
import styles from './style.module.scss'
import { useNavigate } from 'react-router-dom'
import { pubToHex, queryNip05 } from '../../utils' import { pubToHex, queryNip05 } from '../../utils'
import styles from './style.module.scss'
export const Login = () => { export const Login = () => {
const dispatch: Dispatch = useDispatch() const dispatch: Dispatch = useDispatch()
@ -184,7 +183,6 @@ export const Login = () => {
dispatch(updateLoginMethod(LoginMethods.nsecBunker)) dispatch(updateLoginMethod(LoginMethods.nsecBunker))
dispatch(updateNsecbunkerPubkey(pubkey)) dispatch(updateNsecbunkerPubkey(pubkey))
dispatch(updateNsecbunkerRelay(relays![0]))
setLoadingSpinnerDesc('Authenticating and finding metadata') setLoadingSpinnerDesc('Authenticating and finding metadata')
@ -244,7 +242,6 @@ export const Login = () => {
dispatch(updateLoginMethod(LoginMethods.nsecBunker)) dispatch(updateLoginMethod(LoginMethods.nsecBunker))
dispatch(updateNsecbunkerPubkey(pubkey)) dispatch(updateNsecbunkerPubkey(pubkey))
dispatch(updateNsecbunkerRelay(relay))
setLoadingSpinnerDesc('Authenticating and finding metadata') setLoadingSpinnerDesc('Authenticating and finding metadata')

View File

@ -1,69 +0,0 @@
import {
IconButton,
InputAdornment,
List,
ListItem,
ListSubheader,
TextField
} from '@mui/material'
import { ContentCopy } from '@mui/icons-material'
import { useSelector } from 'react-redux'
import { State } from '../../store/rootReducer'
import styles from './style.module.scss'
import { toast } from 'react-toastify'
export const Nsecbunker = () => {
const authState = useSelector((state: State) => state.auth)
const nsecbunkerConnectionString = `bunker://${authState?.nsecBunkerPubkey}?relay=${authState?.nsecbunkerRelay}`
return (
<List
sx={{
bgcolor: 'background.paper',
marginTop: 2
}}
subheader={
<ListSubheader
sx={{
paddingBottom: 1,
paddingTop: 1,
fontSize: '1.5rem'
}}
className={styles.subHeader}
>
Nsecbunker Setting
</ListSubheader>
}
>
<ListItem sx={{ marginTop: 1 }}>
<TextField
label='Nsecbunker connection string'
variant='outlined'
size='small'
className={styles.textField}
value={nsecbunkerConnectionString}
disabled
InputProps={{
endAdornment: (
<InputAdornment position='end'>
<IconButton
aria-label='copy value icon button'
onClick={() => {
navigator.clipboard.writeText(nsecbunkerConnectionString)
toast.success('Copied to clipboard', {
autoClose: 1000,
hideProgressBar: true
})
}}
>
<ContentCopy />
</IconButton>
</InputAdornment>
)
}}
/>
</ListItem>
</List>
)
}

View File

@ -1,7 +0,0 @@
.textField {
width: 100%;
}
.subHeader {
border-bottom: 0.5px solid;
}

View File

@ -1,12 +1,10 @@
import { LandingPage } from '../pages/landing/LandingPage' import { LandingPage } from '../pages/landing/LandingPage'
import { Login } from '../pages/login' import { Login } from '../pages/login'
import { Nsecbunker } from '../pages/nsecbunker'
import { ProfilePage } from '../pages/profile' import { ProfilePage } from '../pages/profile'
import { hexToNpub } from '../utils' import { hexToNpub } from '../utils'
export const appPrivateRoutes = { export const appPrivateRoutes = {
homePage: '/', homePage: '/'
nsecbunker: '/nsecbunker'
} }
export const appPublicRoutes = { export const appPublicRoutes = {
@ -34,9 +32,5 @@ export const privateRoutes = [
{ {
path: appPrivateRoutes.homePage, path: appPrivateRoutes.homePage,
element: <LandingPage /> element: <LandingPage />
},
{
path: appPrivateRoutes.nsecbunker,
element: <Nsecbunker />
} }
] ]

View File

@ -4,6 +4,5 @@ export const SET_AUTH_STATE = 'SET_AUTH_STATE'
export const UPDATE_LOGIN_METHOD = 'UPDATE_LOGIN_METHOD' export const UPDATE_LOGIN_METHOD = 'UPDATE_LOGIN_METHOD'
export const UPDATE_KEYPAIR = 'UPDATE_KEYPAIR' export const UPDATE_KEYPAIR = 'UPDATE_KEYPAIR'
export const UPDATE_NSECBUNKER_PUBKEY = 'UPDATE_NSECBUNKER_PUBKEY' export const UPDATE_NSECBUNKER_PUBKEY = 'UPDATE_NSECBUNKER_PUBKEY'
export const UPDATE_NSECBUNKER_RELAY = 'UPDATE_NSECBUNKER_RELAY'
export const SET_METADATA_EVENT = 'SET_METADATA_EVENT' export const SET_METADATA_EVENT = 'SET_METADATA_EVENT'

View File

@ -6,8 +6,7 @@ import {
SetAuthState, SetAuthState,
UpdateKeyPair, UpdateKeyPair,
UpdateLoginMethod, UpdateLoginMethod,
UpdateNsecBunkerPubkey, UpdateNsecBunkerPubkey
UpdateNsecbunkerRelay
} from './types' } from './types'
export const setAuthState = (payload: AuthState): SetAuthState => ({ export const setAuthState = (payload: AuthState): SetAuthState => ({
@ -33,10 +32,3 @@ export const updateNsecbunkerPubkey = (
type: ActionTypes.UPDATE_NSECBUNKER_PUBKEY, type: ActionTypes.UPDATE_NSECBUNKER_PUBKEY,
payload payload
}) })
export const updateNsecbunkerRelay = (
payload: string | undefined
): UpdateNsecbunkerRelay => ({
type: ActionTypes.UPDATE_NSECBUNKER_RELAY,
payload
})

View File

@ -11,13 +11,12 @@ const reducer = (
): AuthState | null => { ): AuthState | null => {
switch (action.type) { switch (action.type) {
case ActionTypes.SET_AUTH_STATE: { case ActionTypes.SET_AUTH_STATE: {
const { loginMethod, keyPair, nsecBunkerPubkey, nsecbunkerRelay } = state const { loginMethod, keyPair, nsecBunkerPubkey } = state
return { return {
loginMethod, loginMethod,
keyPair, keyPair,
nsecBunkerPubkey, nsecBunkerPubkey,
nsecbunkerRelay,
...action.payload ...action.payload
} }
} }
@ -48,15 +47,6 @@ const reducer = (
} }
} }
case ActionTypes.UPDATE_NSECBUNKER_RELAY: {
const { payload } = action
return {
...state,
nsecbunkerRelay: payload
}
}
default: default:
return state return state
} }

View File

@ -18,7 +18,6 @@ export interface AuthState {
loginMethod?: LoginMethods loginMethod?: LoginMethods
keyPair?: Keys keyPair?: Keys
nsecBunkerPubkey?: string nsecBunkerPubkey?: string
nsecbunkerRelay?: string
} }
export interface SetAuthState { export interface SetAuthState {
@ -41,14 +40,8 @@ export interface UpdateNsecBunkerPubkey {
payload: string | undefined payload: string | undefined
} }
export interface UpdateNsecbunkerRelay {
type: typeof ActionTypes.UPDATE_NSECBUNKER_RELAY
payload: string | undefined
}
export type AuthDispatchTypes = export type AuthDispatchTypes =
| SetAuthState | SetAuthState
| UpdateLoginMethod | UpdateLoginMethod
| UpdateKeyPair | UpdateKeyPair
| UpdateNsecBunkerPubkey | UpdateNsecBunkerPubkey
| UpdateNsecbunkerRelay