mirror of
https://github.com/status-im/dappconnect-sdks.git
synced 2025-01-27 17:05:33 +00:00
feat(react): use correct types in chat context
This commit is contained in:
parent
f309ba291b
commit
25c2759baa
@ -1,5 +1,6 @@
|
|||||||
import React, { createContext, useContext, useMemo, useReducer } from 'react'
|
import React, { createContext, useContext, useMemo, useReducer } from 'react'
|
||||||
|
|
||||||
|
import type { Message } from '../protocol/use-messages'
|
||||||
import type { Dispatch, Reducer } from 'react'
|
import type { Dispatch, Reducer } from 'react'
|
||||||
|
|
||||||
type Context = {
|
type Context = {
|
||||||
@ -9,12 +10,6 @@ type Context = {
|
|||||||
|
|
||||||
const ChatContext = createContext<Context | undefined>(undefined)
|
const ChatContext = createContext<Context | undefined>(undefined)
|
||||||
|
|
||||||
// TODO: Take from generated protobuf
|
|
||||||
export interface Message {
|
|
||||||
type: 'text' | 'image' | 'image-text'
|
|
||||||
text?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
interface State {
|
interface State {
|
||||||
message?: Message
|
message?: Message
|
||||||
}
|
}
|
||||||
@ -51,7 +46,7 @@ export const ChatProvider = (props: Props) => {
|
|||||||
return <ChatContext.Provider value={value}>{children}</ChatContext.Provider>
|
return <ChatContext.Provider value={value}>{children}</ChatContext.Provider>
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useChatState = () => {
|
export const useChatContext = () => {
|
||||||
const context = useContext(ChatContext)
|
const context = useContext(ChatContext)
|
||||||
|
|
||||||
if (!context) {
|
if (!context) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user