@@ -2,16 +2,25 @@ import * as React from 'react';
2
2
import { PullRequest } from './cache' ;
3
3
import PullRequestContext from './context' ;
4
4
import { groupBy } from 'lodash' ;
5
- import { useContext , useReducer , useRef , useState } from 'react' ;
5
+ import { useContext , useReducer , useRef , useState , useEffect } from 'react' ;
6
6
import { PullRequestStateEnum , MergeMethod } from '../src/github/interface' ;
7
7
import { checkIcon , deleteIcon , pendingIcon } from './icon' ;
8
8
import { Avatar , } from './user' ;
9
9
import { nbsp } from './space' ;
10
10
11
11
export const StatusChecks = ( pr : PullRequest ) => {
12
12
const { state, status, mergeable } = pr ;
13
- const [ showDetails , toggleDetails ] = useReducer ( show => ! show ,
14
- status . statuses . some ( s => s . state === 'failure' ) ) ;
13
+ const [ showDetails , toggleDetails ] = useReducer (
14
+ show => ! show ,
15
+ status . statuses . some ( s => s . state === 'failure' ) ) as [ boolean , ( ) => void ] ;
16
+
17
+ useEffect ( ( ) => {
18
+ if ( status . statuses . some ( s => s . state === 'failure' ) ) {
19
+ if ( ! showDetails ) { toggleDetails ( ) ; }
20
+ } else {
21
+ if ( showDetails ) { toggleDetails ( ) ; }
22
+ }
23
+ } , status . statuses ) ;
15
24
16
25
return < div id = 'status-checks' > {
17
26
state === PullRequestStateEnum . Merged
0 commit comments