@@ -24,6 +24,7 @@ import {initRepoPullRequestCommitStatus} from './repo-issue-pr-status.js';
24
24
import { hideElem , showElem } from '../utils/dom.js' ;
25
25
import { getComboMarkdownEditor , initComboMarkdownEditor } from './comp/ComboMarkdownEditor.js' ;
26
26
import { attachRefIssueContextPopup } from './contextpopup.js' ;
27
+ import { POST } from '../modules/fetch.js' ;
27
28
28
29
const { csrfToken} = window . config ;
29
30
@@ -65,7 +66,7 @@ export function initRepoCommentForm() {
65
66
const $selectBranch = $ ( '.ui.select-branch' ) ;
66
67
const $branchMenu = $selectBranch . find ( '.reference-list-menu' ) ;
67
68
const $isNewIssue = $branchMenu . hasClass ( 'new-issue' ) ;
68
- $branchMenu . find ( '.item:not(.no-select)' ) . on ( 'click' , function ( ) {
69
+ $branchMenu . find ( '.item:not(.no-select)' ) . on ( 'click' , async function ( ) {
69
70
const selectedValue = $ ( this ) . data ( 'id' ) ;
70
71
const editMode = $ ( '#editing_mode' ) . val ( ) ;
71
72
$ ( $ ( this ) . data ( 'id-selector' ) ) . val ( selectedValue ) ;
@@ -76,7 +77,14 @@ export function initRepoCommentForm() {
76
77
77
78
if ( editMode === 'true' ) {
78
79
const form = $ ( '#update_issueref_form' ) ;
79
- $ . post ( form . attr ( 'action' ) , { _csrf : csrfToken , ref : selectedValue } , ( ) => window . location . reload ( ) ) ;
80
+ const params = new URLSearchParams ( ) ;
81
+ params . append ( 'ref' , selectedValue ) ;
82
+ try {
83
+ await POST ( form . attr ( 'action' ) , { data : params } ) ;
84
+ window . location . reload ( ) ;
85
+ } catch ( error ) {
86
+ console . error ( 'Error:' , error ) ;
87
+ }
80
88
} else if ( editMode === '' ) {
81
89
$selectBranch . find ( '.ui .branch-name' ) . text ( selectedValue ) ;
82
90
}
0 commit comments