feat: favorite relays (#250)
This commit is contained in:
parent
fab9ff88b5
commit
c739d9d28c
63 changed files with 1081 additions and 982 deletions
40
src/components/FavoriteRelaysSetting/provider.tsx
Normal file
40
src/components/FavoriteRelaysSetting/provider.tsx
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
import { createContext, useContext, useState } from 'react'
|
||||
|
||||
type TRelaySetsSettingComponentContext = {
|
||||
renamingRelaySetId: string | null
|
||||
setRenamingRelaySetId: React.Dispatch<React.SetStateAction<string | null>>
|
||||
expandedRelaySetId: string | null
|
||||
setExpandedRelaySetId: React.Dispatch<React.SetStateAction<string | null>>
|
||||
}
|
||||
|
||||
export const RelaySetsSettingComponentContext = createContext<
|
||||
TRelaySetsSettingComponentContext | undefined
|
||||
>(undefined)
|
||||
|
||||
export const useRelaySetsSettingComponent = () => {
|
||||
const context = useContext(RelaySetsSettingComponentContext)
|
||||
if (!context) {
|
||||
throw new Error(
|
||||
'useRelaySetsSettingComponent must be used within a RelaySetsSettingComponentProvider'
|
||||
)
|
||||
}
|
||||
return context
|
||||
}
|
||||
|
||||
export function RelaySetsSettingComponentProvider({ children }: { children: React.ReactNode }) {
|
||||
const [renamingRelaySetId, setRenamingRelaySetId] = useState<string | null>(null)
|
||||
const [expandedRelaySetId, setExpandedRelaySetId] = useState<string | null>(null)
|
||||
|
||||
return (
|
||||
<RelaySetsSettingComponentContext.Provider
|
||||
value={{
|
||||
renamingRelaySetId,
|
||||
setRenamingRelaySetId,
|
||||
expandedRelaySetId,
|
||||
setExpandedRelaySetId
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</RelaySetsSettingComponentContext.Provider>
|
||||
)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue