Skip to content

Commit cc07b9c

Browse files
a1012112796lafrikstechknowlogickguillep2k
authored
Fix CreateComment for SQLite and JS click event on Request Review (#11040)
* fix some bug about Request review * fix ``CreateComment`` wrong using ,it will not work when use Sqlite * fix wrong js click event code , it will send wrong data when it has many choices Signed-off-by: a1012112796 <[email protected]> * Apply suggestions from code review Co-Authored-By: Lauris BH <[email protected]> * add getReviewerByIssueIDAndUserID fix wrong conditions check in initIssueComments after #10972 * call CI again Co-authored-by: Lauris BH <[email protected]> Co-authored-by: techknowlogick <[email protected]> Co-authored-by: guillep2k <[email protected]>
1 parent 8592fb7 commit cc07b9c

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

models/review.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -395,9 +395,13 @@ func GetReviewersByIssueID(issueID int64) (reviews []*Review, err error) {
395395

396396
// GetReviewerByIssueIDAndUserID get the latest review of reviewer for a pull request
397397
func GetReviewerByIssueIDAndUserID(issueID, userID int64) (review *Review, err error) {
398+
return getReviewerByIssueIDAndUserID(x, issueID, userID)
399+
}
400+
401+
func getReviewerByIssueIDAndUserID(e Engine, issueID, userID int64) (review *Review, err error) {
398402
review = new(Review)
399403

400-
if _, err := x.SQL("SELECT * FROM review WHERE id IN (SELECT max(id) as id FROM review WHERE issue_id = ? AND reviewer_id = ? AND type in (?, ?, ?))",
404+
if _, err := e.SQL("SELECT * FROM review WHERE id IN (SELECT max(id) as id FROM review WHERE issue_id = ? AND reviewer_id = ? AND type in (?, ?, ?))",
401405
issueID, userID, ReviewTypeApprove, ReviewTypeReject, ReviewTypeRequest).
402406
Get(review); err != nil {
403407
return nil, err
@@ -559,7 +563,7 @@ func RemoveRewiewRequest(issue *Issue, reviewer *User, doer *User) (comment *Com
559563
// recalculate which is the latest official review from that user
560564
var review *Review
561565

562-
review, err = GetReviewerByIssueIDAndUserID(issue.ID, reviewer.ID)
566+
review, err = getReviewerByIssueIDAndUserID(sess, issue.ID, reviewer.ID)
563567
if err != nil {
564568
return nil, err
565569
}
@@ -575,7 +579,7 @@ func RemoveRewiewRequest(issue *Issue, reviewer *User, doer *User) (comment *Com
575579
return nil, err
576580
}
577581

578-
comment, err = CreateComment(&CreateCommentOptions{
582+
comment, err = createComment(sess, &CreateCommentOptions{
579583
Type: CommentTypeReviewRequest,
580584
Doer: doer,
581585
Repo: issue.Repo,

web_src/js/index.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -661,17 +661,21 @@ function initInstall() {
661661
}
662662

663663
function initIssueComments() {
664-
if ($('.repository.view.issue .comments').length === 0) return;
664+
if ($('.repository.view.issue .timeline').length === 0) return;
665+
666+
$('.re-request-review').on('click', function (event) {
667+
const url = $(this).data('update-url');
668+
const issueId = $(this).data('issue-id');
669+
const id = $(this).data('id');
670+
const isChecked = $(this).data('is-checked');
665671

666-
$('.re-request-review').click((event) => {
667-
const $this = $('.re-request-review');
668672
event.preventDefault();
669673
updateIssuesMeta(
670-
$this.data('update-url'),
674+
url,
671675
'',
672-
$this.data('issue-id'),
673-
$this.data('id'),
674-
$this.data('is-checked')
676+
issueId,
677+
id,
678+
isChecked
675679
).then(reload);
676680
});
677681

0 commit comments

Comments
 (0)