Skip to content

Commit

Permalink
refactor: remove type ServiceInfoUpdate
Browse files Browse the repository at this point in the history
  • Loading branch information
theborakompanioni committed Sep 23, 2023
1 parent 3a71a7a commit 465c023
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/context/ServiceInfoContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,6 @@ type ServiceInfo = SessionFlag &
RescanBlockchainInProgressFlag &
SessionInfo &
ServerInfo
type ServiceInfoUpdate =
| ServiceInfo
| MakerRunningFlag
| CoinjoinInProgressFlag
| RescanBlockchainInProgressFlag
| ServerInfo

const versionRegex = new RegExp(/^(\d+)\.(\d+)\.(\d+).*$/)
const toSemVer = (data: JmGetInfoData): SemVer => {
Expand All @@ -107,7 +101,7 @@ const toSemVer = (data: JmGetInfoData): SemVer => {
interface ServiceInfoContextEntry {
serviceInfo: ServiceInfo | null
reloadServiceInfo: ({ signal }: { signal: AbortSignal }) => Promise<ServiceInfo>
dispatchServiceInfo: React.Dispatch<ServiceInfoUpdate>
dispatchServiceInfo: React.Dispatch<Partial<ServiceInfo>>
connectionError?: Error
}

Expand All @@ -121,7 +115,7 @@ const ServiceInfoProvider = ({ children }: React.PropsWithChildren<{}>) => {
const fetchSessionInProgress = useRef<Promise<ServiceInfo> | null>(null)

const [serviceInfo, dispatchServiceInfo] = useReducer(
(state: ServiceInfo | null, obj: ServiceInfoUpdate) => ({ ...state, ...obj }) as ServiceInfo | null,
(state: ServiceInfo | null, obj: Partial<ServiceInfo>) => ({ ...state, ...obj }) as ServiceInfo | null,
null,
)
const [connectionError, setConnectionError] = useState<Error>()
Expand Down

0 comments on commit 465c023

Please sign in to comment.