@@ -947,21 +947,19 @@ async function initRepository() {
947
947
const $conversation = $ ( e . currentTarget ) . closest ( '.comment-code-cloud' ) ;
948
948
const $conversations = $ ( '.comment-code-cloud:not(.hide)' ) ;
949
949
const index = $conversations . index ( $conversation ) ;
950
- if ( index !== 0 ) {
951
- const $previousConversation = $conversations . eq ( index - 1 ) ;
952
- const anchor = $previousConversation . find ( '.comment' ) . first ( ) . attr ( 'id' ) ;
953
- window . location . href = `#${ anchor } ` ;
954
- }
950
+ const previousIndex = index > 0 ? index - 1 : $conversations . length - 1 ;
951
+ const $previousConversation = $conversations . eq ( previousIndex ) ;
952
+ const anchor = $previousConversation . find ( '.comment' ) . first ( ) . attr ( 'id' ) ;
953
+ window . location . href = `#${ anchor } ` ;
955
954
} ) ;
956
955
$ ( document ) . on ( 'click' , '.next-conversation' , ( e ) => {
957
956
const $conversation = $ ( e . currentTarget ) . closest ( '.comment-code-cloud' ) ;
958
957
const $conversations = $ ( '.comment-code-cloud:not(.hide)' ) ;
959
958
const index = $conversations . index ( $conversation ) ;
960
- if ( index !== $conversations . length - 1 ) {
961
- const $nextConversation = $conversations . eq ( index + 1 ) ;
962
- const anchor = $nextConversation . find ( '.comment' ) . first ( ) . attr ( 'id' ) ;
963
- window . location . href = `#${ anchor } ` ;
964
- }
959
+ const nextIndex = index < $conversations . length - 1 ? index + 1 : 0 ;
960
+ const $nextConversation = $conversations . eq ( nextIndex ) ;
961
+ const anchor = $nextConversation . find ( '.comment' ) . first ( ) . attr ( 'id' ) ;
962
+ window . location . href = `#${ anchor } ` ;
965
963
} ) ;
966
964
967
965
// Quote reply
0 commit comments