File tree 2 files changed +8
-0
lines changed
2 files changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ type User = {
30
30
export default function App ( ) {
31
31
const [ messages , setMessages ] = useState < Message [ ] > ( [ ] ) ;
32
32
const [ loading , setLoading ] = useState < boolean > ( false ) ;
33
+ const [ chatLoading , setChatloading ] = useState ( true ) ;
33
34
const [ auth , setAuth ] = useState < User | undefined > ( ( ) => {
34
35
const user = localStorage . getItem ( "auth" ) ;
35
36
if ( ! user ) return undefined ;
@@ -69,6 +70,9 @@ export default function App() {
69
70
} )
70
71
. catch ( ( err ) => {
71
72
console . log ( err ) ;
73
+ } )
74
+ . finally ( ( ) => {
75
+ setChatloading ( false ) ;
72
76
} ) ;
73
77
} , [ auth ] ) ;
74
78
@@ -108,6 +112,7 @@ export default function App() {
108
112
) }
109
113
110
114
< Input
115
+ chatLoading = { chatLoading }
111
116
handlelogout = { handlelogout }
112
117
img = { auth ?. avatar }
113
118
apiKey = { auth ?. apiKey }
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ type InputProps = {
10
10
apiKey : string ;
11
11
img : string ;
12
12
handlelogout : ( ) => void ;
13
+ chatLoading : boolean ;
13
14
} ;
14
15
15
16
export default function Input ( {
@@ -18,6 +19,7 @@ export default function Input({
18
19
apiKey,
19
20
img,
20
21
handlelogout,
22
+ chatLoading,
21
23
} : InputProps ) {
22
24
const [ input , setInput ] = useState < string > ( "" ) ;
23
25
function handleInput ( ) {
@@ -69,6 +71,7 @@ export default function Input({
69
71
} }
70
72
>
71
73
< input
74
+ disabled = { chatLoading }
72
75
autoFocus = { true }
73
76
onKeyDown = { ( e ) => e . keyCode === 13 && input != "" && handleInput ( ) }
74
77
onChange = { ( e ) => setInput ( e . target . value ) }
You can’t perform that action at this time.
0 commit comments