@@ -286,38 +286,20 @@ TEST: addTests('isQuickPR', [
286
286
'https://github.com/sindresorhus/refined-github/compare/test-branch?quick_pull=1' ,
287
287
] ) ;
288
288
289
- const stateSelector = [
290
- '.State' ,
291
- '[data-testid="header-state"]' ,
292
- ] . join ( ',' ) ;
293
-
294
- export const isDraftPR = ( ) : boolean => $ ( stateSelector ) ?. textContent ! . trim ( ) === 'Draft' ;
295
- export const isOpenPR = ( ) : boolean => {
296
- if ( ! isPR ( ) ) {
297
- return false ;
298
- }
299
-
300
- const status = $ ( stateSelector ) ! . textContent ! . trim ( ) ;
289
+ const getStateLabel = ( ) : string | undefined => $ ( [
290
+ '.State' , // Old view
291
+ '[class^="StateLabel"]' , // React version
292
+ ] . join ( ',' ) ) ?. textContent ?. trim ( ) ;
293
+
294
+ export const isMergedPR = ( ) : boolean => getStateLabel ( ) === 'Merged' ;
295
+ export const isDraftPR = ( ) : boolean => getStateLabel ( ) === 'Draft' ;
296
+ export const isOpenConversation = ( ) : boolean => {
297
+ const status = getStateLabel ( ) ;
301
298
return status === 'Open' || status === 'Draft' ;
302
299
} ;
303
300
304
- export const isMergedPR = ( ) : boolean => $ ( stateSelector ) ?. textContent ! . trim ( ) === 'Merged' ;
305
-
306
- export const isClosedPR = ( ) : boolean => {
307
- if ( ! isPR ( ) ) {
308
- return false ;
309
- }
310
-
311
- const status = $ ( stateSelector ) ! . textContent ! . trim ( ) ;
312
- return status === 'Closed' || status === 'Merged' ;
313
- } ;
314
-
315
- export const isClosedIssue = ( ) : boolean => {
316
- if ( ! isIssue ( ) ) {
317
- return false ;
318
- }
319
-
320
- const status = $ ( stateSelector ) ! . textContent ! . trim ( ) ;
301
+ export const isClosedConversation = ( ) : boolean => {
302
+ const status = getStateLabel ( ) ;
321
303
return status === 'Closed' || status === 'Closed as not planned' ;
322
304
} ;
323
305
0 commit comments