Skip to content

Commit 3992696

Browse files
author
Ashi Krishnan
committed
Toggle the status checks open state when statuses update.
Co-Authored-By: [email protected]
1 parent 42e5c8b commit 3992696

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

preview-src/merge.tsx

+12-3
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,25 @@ import * as React from 'react';
22
import { PullRequest } from './cache';
33
import PullRequestContext from './context';
44
import { groupBy } from 'lodash';
5-
import { useContext, useReducer, useRef, useState } from 'react';
5+
import { useContext, useReducer, useRef, useState, useEffect } from 'react';
66
import { PullRequestStateEnum, MergeMethod } from '../src/github/interface';
77
import { checkIcon, deleteIcon, pendingIcon } from './icon';
88
import { Avatar, } from './user';
99
import { nbsp } from './space';
1010

1111
export const StatusChecks = (pr: PullRequest) => {
1212
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);
1524

1625
return <div id='status-checks'>{
1726
state === PullRequestStateEnum.Merged

0 commit comments

Comments
 (0)