File tree Expand file tree Collapse file tree 1 file changed +4
-8
lines changed
site/src/modules/templates Expand file tree Collapse file tree 1 file changed +4
-8
lines changed Original file line number Diff line number Diff line change @@ -7,12 +7,12 @@ export const useWatchVersionLogs = (
7
7
templateVersion : TemplateVersion | undefined ,
8
8
options ?: { onDone : ( ) => Promise < unknown > } ,
9
9
) => {
10
- const [ logs , setLogs ] = useState < ProvisionerJobLog [ ] > ( ) ;
10
+ const [ logs , setLogs ] = useState < ProvisionerJobLog [ ] > ( [ ] ) ;
11
11
const templateVersionId = templateVersion ?. id ;
12
12
const [ cachedVersionId , setCachedVersionId ] = useState ( templateVersionId ) ;
13
13
if ( cachedVersionId !== templateVersionId ) {
14
14
setCachedVersionId ( templateVersionId ) ;
15
- setLogs ( undefined ) ;
15
+ setLogs ( [ ] ) ;
16
16
}
17
17
18
18
const stableOnDone = useEffectEvent ( ( ) => options ?. onDone ( ) ) ;
@@ -24,13 +24,9 @@ export const useWatchVersionLogs = (
24
24
}
25
25
26
26
const socket = watchBuildLogsByTemplateVersionId ( templateVersionId , {
27
- onMessage : ( log ) => {
28
- setLogs ( ( logs ) => ( logs ? [ ...logs , log ] : [ log ] ) ) ;
29
- } ,
27
+ onMessage : ( newLog ) => setLogs ( ( current ) => [ ...current , newLog ] ) ,
28
+ onError : ( error ) => console . error ( error ) ,
30
29
onDone : stableOnDone ,
31
- onError : ( error ) => {
32
- console . error ( error ) ;
33
- } ,
34
30
} ) ;
35
31
36
32
return ( ) => socket . close ( ) ;
You can’t perform that action at this time.
0 commit comments